Class: Rbgraph::Edge
- Inherits:
-
Object
- Object
- Rbgraph::Edge
- Defined in:
- lib/rbgraph/edge.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#node1 ⇒ Object
Returns the value of attribute node1.
-
#node2 ⇒ Object
Returns the value of attribute node2.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(node1, node2, attributes = {}) ⇒ Edge
constructor
A new instance of Edge.
- #merge(edge) ⇒ Object
Constructor Details
#initialize(node1, node2, attributes = {}) ⇒ Edge
Returns a new instance of Edge.
10 11 12 13 14 15 |
# File 'lib/rbgraph/edge.rb', line 10 def initialize(node1, node2, attributes = {}) self.node1 = node1 self.node2 = node2 self.attributes = attributes self.id = attributes[:id] || "#{node1.id}=#{self.class}=#{node2.id}" end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/rbgraph/edge.rb', line 8 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/rbgraph/edge.rb', line 5 def id @id end |
#node1 ⇒ Object
Returns the value of attribute node1.
6 7 8 |
# File 'lib/rbgraph/edge.rb', line 6 def node1 @node1 end |
#node2 ⇒ Object
Returns the value of attribute node2.
7 8 9 |
# File 'lib/rbgraph/edge.rb', line 7 def node2 @node2 end |
Instance Method Details
#hash ⇒ Object
22 23 24 |
# File 'lib/rbgraph/edge.rb', line 22 def hash id end |
#merge(edge) ⇒ Object
26 27 28 29 |
# File 'lib/rbgraph/edge.rb', line 26 def merge(edge) attributes.merge!(edge.attributes.reject { |k, v| k == :id }) self end |