Class: CyclicLink

Inherits:
Object
  • Object
show all
Defined in:
lib/cpp_dependency_graph/cyclic_link.rb

Overview

A special class designed to be used as a key in a hash

Instance Method Summary collapse

Constructor Details

#initialize(nodeA, nodeB) ⇒ CyclicLink

Returns a new instance of CyclicLink.



5
6
7
8
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 5

def initialize(nodeA, nodeB)
  @nodeA = nodeA
  @nodeB = nodeB
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 18

def eql?(other)
  (@nodeA == other.nodeA && @nodeB == other.nodeB) ||
  (@nodeA == other.nodeB && @nodeB == other.nodeA)
end

#hashObject



23
24
25
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 23

def hash
  [@nodeA, @nodeB].to_set.hash
end

#nodeAObject



10
11
12
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 10

def nodeA
  @nodeA
end

#nodeBObject



14
15
16
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 14

def nodeB
  @nodeB
end

#to_sObject



27
28
29
# File 'lib/cpp_dependency_graph/cyclic_link.rb', line 27

def to_s
  "#{nodeA} <-> #{nodeB}"
end