Class: DepsGrapher::Edge
- Inherits:
-
Object
- Object
- DepsGrapher::Edge
- Defined in:
- lib/deps_grapher/edge.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#id ⇒ Object
Returns the value of attribute id.
-
#to ⇒ Object
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(id, from, to) ⇒ Edge
constructor
A new instance of Edge.
Constructor Details
#initialize(id, from, to) ⇒ Edge
Returns a new instance of Edge.
43 44 45 46 47 |
# File 'lib/deps_grapher/edge.rb', line 43 def initialize(id, from, to) @id = id @from = from @to = to end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
41 42 43 |
# File 'lib/deps_grapher/edge.rb', line 41 def from @from end |
#id ⇒ Object
Returns the value of attribute id.
41 42 43 |
# File 'lib/deps_grapher/edge.rb', line 41 def id @id end |
#to ⇒ Object
Returns the value of attribute to.
41 42 43 |
# File 'lib/deps_grapher/edge.rb', line 41 def to @to end |
Class Method Details
.add(from, to) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/deps_grapher/edge.rb', line 11 def add(from, to) return nil if from.nil? || to.nil? id = generate_id from, to return nil if registry.key?(id) || from.id == to.id to.parent = from.id to.increment_deps_count! registry[id] = new id, from, to end |
.all ⇒ Object
24 25 26 |
# File 'lib/deps_grapher/edge.rb', line 24 def all registry.values end |
.fetch(from, to) ⇒ Object
6 7 8 9 |
# File 'lib/deps_grapher/edge.rb', line 6 def fetch(from, to) id = generate_id from, to registry.fetch id end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
49 50 51 |
# File 'lib/deps_grapher/edge.rb', line 49 def eql?(other) other.is_a?(self.class) && id == other.id end |
#hash ⇒ Object
54 55 56 |
# File 'lib/deps_grapher/edge.rb', line 54 def hash id.hash end |