Class: PatchworkInternal::Link
- Inherits:
-
Object
- Object
- PatchworkInternal::Link
- Defined in:
- lib/patchwork/link.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#directed ⇒ Object
Returns the value of attribute directed.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#node_end ⇒ Object
readonly
Returns the value of attribute node_end.
-
#node_start ⇒ Object
readonly
Returns the value of attribute node_start.
Instance Method Summary collapse
-
#initialize(node_a, node_b, directed, cost) ⇒ Link
constructor
A new instance of Link.
- #links_to(node) ⇒ Object
Constructor Details
#initialize(node_a, node_b, directed, cost) ⇒ Link
Returns a new instance of Link.
8 9 10 11 12 13 14 |
# File 'lib/patchwork/link.rb', line 8 def initialize(node_a, node_b, directed, cost) @node_start = node_a @node_end = node_b @directed = directed @cost = cost @id = SecureRandom.uuid end |
Instance Attribute Details
#cost ⇒ Object
Returns the value of attribute cost.
6 7 8 |
# File 'lib/patchwork/link.rb', line 6 def cost @cost end |
#directed ⇒ Object
Returns the value of attribute directed.
6 7 8 |
# File 'lib/patchwork/link.rb', line 6 def directed @directed end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/patchwork/link.rb', line 5 def id @id end |
#node_end ⇒ Object (readonly)
Returns the value of attribute node_end.
5 6 7 |
# File 'lib/patchwork/link.rb', line 5 def node_end @node_end end |
#node_start ⇒ Object (readonly)
Returns the value of attribute node_start.
5 6 7 |
# File 'lib/patchwork/link.rb', line 5 def node_start @node_start end |
Instance Method Details
#links_to(node) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/patchwork/link.rb', line 16 def links_to(node) if @directed == true node == @node_end else node == @node_start || node == @node_end end end |