Class: CyclicLink
- Inherits:
-
Object
- Object
- CyclicLink
- Defined in:
- lib/cpp_dependency_graph/cyclic_link.rb
Overview
Represents a cyclic link betwee two nodes, it is special in the sense it is designed to be used as a key in a hash
Instance Attribute Summary collapse
-
#node_a ⇒ Object
readonly
Returns the value of attribute node_a.
-
#node_b ⇒ Object
readonly
Returns the value of attribute node_b.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(node_a, node_b) ⇒ CyclicLink
constructor
A new instance of CyclicLink.
- #to_s ⇒ Object
Constructor Details
#initialize(node_a, node_b) ⇒ CyclicLink
10 11 12 13 |
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 10 def initialize(node_a, node_b) @node_a = node_a @node_b = node_b end |
Instance Attribute Details
#node_a ⇒ Object (readonly)
Returns the value of attribute node_a.
7 8 9 |
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 7 def node_a @node_a end |
#node_b ⇒ Object (readonly)
Returns the value of attribute node_b.
8 9 10 |
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 8 def node_b @node_b end |
Instance Method Details
#eql?(other) ⇒ Boolean
15 16 17 18 |
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 15 def eql?(other) (@node_a == other.node_a && @node_b == other.node_b) || (@node_a == other.node_b && @node_b == other.node_a) end |
#hash ⇒ Object
20 21 22 |
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 20 def hash [@node_a, @node_b].to_set.hash end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 24 def to_s "#{node_a} <-> #{node_b}" end |