Class: Seafoam::Edge
- Inherits:
-
Object
- Object
- Seafoam::Edge
- Defined in:
- lib/seafoam/graph.rb
Overview
A directed edge, with a node it’s from and a node it’s going to, and properties.
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(from, to, props = nil) ⇒ Edge
constructor
A new instance of Edge.
-
#inspect ⇒ Object
Inspect.
-
#nodes ⇒ Object
Both nodes - from and to.
Constructor Details
#initialize(from, to, props = nil) ⇒ Edge
Returns a new instance of Edge.
91 92 93 94 95 96 |
# File 'lib/seafoam/graph.rb', line 91 def initialize(from, to, props = nil) props ||= {} @from = from @to = to @props = props end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
89 90 91 |
# File 'lib/seafoam/graph.rb', line 89 def from @from end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
89 90 91 |
# File 'lib/seafoam/graph.rb', line 89 def props @props end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
89 90 91 |
# File 'lib/seafoam/graph.rb', line 89 def to @to end |
Instance Method Details
#inspect ⇒ Object
Inspect.
104 105 106 |
# File 'lib/seafoam/graph.rb', line 104 def inspect "<Edge #{from.id} -> #{to.id}>" end |
#nodes ⇒ Object
Both nodes - from and to.
99 100 101 |
# File 'lib/seafoam/graph.rb', line 99 def nodes [@from, @to] end |