Class: DPTM6::Path::Node
- Inherits:
-
Object
- Object
- DPTM6::Path::Node
- Defined in:
- lib/dptm6/path.rb
Instance Attribute Summary collapse
-
#next ⇒ Object
Returns the value of attribute next.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#prev ⇒ Object
Returns the value of attribute prev.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #connect(next_node) ⇒ Object
-
#initialize(x, y, op) ⇒ Node
constructor
A new instance of Node.
- #output(op = @op) ⇒ Object
- #reconnect(opp_node) ⇒ Object
Constructor Details
#initialize(x, y, op) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 |
# File 'lib/dptm6/path.rb', line 6 def initialize(x, y, op) @x = x.to_f @y = y.to_f @op = op.to_sym end |
Instance Attribute Details
#next ⇒ Object
Returns the value of attribute next.
4 5 6 |
# File 'lib/dptm6/path.rb', line 4 def next @next end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
3 4 5 |
# File 'lib/dptm6/path.rb', line 3 def op @op end |
#prev ⇒ Object
Returns the value of attribute prev.
4 5 6 |
# File 'lib/dptm6/path.rb', line 4 def prev @prev end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
3 4 5 |
# File 'lib/dptm6/path.rb', line 3 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
3 4 5 |
# File 'lib/dptm6/path.rb', line 3 def y @y end |
Instance Method Details
#connect(next_node) ⇒ Object
12 13 14 15 16 |
# File 'lib/dptm6/path.rb', line 12 def connect(next_node) self.next = next_node next_node.prev = self self end |
#output(op = @op) ⇒ Object
29 30 31 32 |
# File 'lib/dptm6/path.rb', line 29 def output(op = @op) @op = nil "%g %g %s " % [@x, @y, op] end |
#reconnect(opp_node) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dptm6/path.rb', line 18 def reconnect(opp_node) # assume that self.x == opp_node.x && self.y == opp_node.y if (self.next.x == opp_node.prev.x && self.next.y == opp_node.prev.y) opp_node.prev.connect(self.next) self.connect(opp_node) self else nil end end |