Class: NoSE::QueryGraph::Edge
Overview
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Edges are equal if the canonical parameters used to construct them are the same.
-
#canonical_params ⇒ Array
Produce the parameters to initialize the canonical version of this edge (this accounts for different directionality of edges).
- #hash ⇒ Object
-
#initialize(from, to, key) ⇒ Edge
constructor
A new instance of Edge.
-
#inspect ⇒ Object
:nocov:.
Constructor Details
#initialize(from, to, key) ⇒ Edge
Returns a new instance of Edge.
37 38 39 40 41 |
# File 'lib/nose/query_graph.rb', line 37 def initialize(from, to, key) @from = from @to = to @key = key end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
35 36 37 |
# File 'lib/nose/query_graph.rb', line 35 def from @from end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
35 36 37 |
# File 'lib/nose/query_graph.rb', line 35 def key @key end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
35 36 37 |
# File 'lib/nose/query_graph.rb', line 35 def to @to end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Edges are equal if the canonical parameters used to construct them are the same
51 52 53 54 |
# File 'lib/nose/query_graph.rb', line 51 def ==(other) return false unless other.is_a? Edge canonical_params == other.canonical_params end |
#canonical_params ⇒ Array
Produce the parameters to initialize the canonical version of this edge (this accounts for different directionality of edges)
64 65 66 67 68 69 70 |
# File 'lib/nose/query_graph.rb', line 64 def canonical_params if @from.entity.name > @to.entity.name [@from.entity.name, @to.entity.name, @key.name] else [@to.entity.name, @from.entity.name, @key.reverse.name] end end |
#hash ⇒ Object
57 58 59 |
# File 'lib/nose/query_graph.rb', line 57 def hash canonical_params.hash end |
#inspect ⇒ Object
:nocov:
44 45 46 |
# File 'lib/nose/query_graph.rb', line 44 def inspect @key.inspect end |