Class: Savage::Path
- Inherits:
-
Object
- Object
- Savage::Path
- Includes:
- DirectionProxy, Utils
- Defined in:
- lib/savage/path.rb
Instance Attribute Summary collapse
-
#subpaths ⇒ Object
Returns the value of attribute subpaths.
Instance Method Summary collapse
- #closed? ⇒ Boolean
- #directions ⇒ Object
-
#initialize(*args) {|_self| ... } ⇒ Path
constructor
A new instance of Path.
- #move_to(*args) ⇒ Object
- #to_command ⇒ Object
Methods included from DirectionProxy
Methods included from Utils
Constructor Details
Instance Attribute Details
#subpaths ⇒ Object
Returns the value of attribute subpaths.
9 10 11 |
# File 'lib/savage/path.rb', line 9 def subpaths @subpaths end |
Instance Method Details
#closed? ⇒ Boolean
37 38 39 |
# File 'lib/savage/path.rb', line 37 def closed? @subpaths.last.closed? end |
#directions ⇒ Object
23 24 25 26 27 |
# File 'lib/savage/path.rb', line 23 def directions directions = [] @subpaths.each { |subpath| directions.concat(subpath.directions) } directions end |
#move_to(*args) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/savage/path.rb', line 29 def move_to(*args) unless (@subpaths.last.directions.empty?) (@subpaths << SubPath.new(*args)).last else @subpaths.last.move_to(*args) end end |
#to_command ⇒ Object
41 42 43 |
# File 'lib/savage/path.rb', line 41 def to_command @subpaths.collect { |subpath| subpath.to_command }.join end |