diff options
| author | mo k <mo@mokhan.ca> | 2012-11-06 21:19:35 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-11-06 21:19:35 -0700 |
| commit | 1cbfb78eb22d2b16200e2d02451e3c07db7a6a59 (patch) | |
| tree | cd1e6b99a6e1969a8a189b0a620275745fda23f5 | |
| parent | ab0718b1b16ed77808c2ef9c4bbef86e1369cf34 (diff) | |
extract run_against method.
| -rw-r--r-- | lib/navigate_rover.rb | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/navigate_rover.rb b/lib/navigate_rover.rb index 4ac80b5..fb9b943 100644 --- a/lib/navigate_rover.rb +++ b/lib/navigate_rover.rb @@ -1,10 +1,3 @@ -require "plateau" -require "specification" -require "filtered_command" -require "move_forward" -require "turn_left" -require "turn_right" - class NavigateRover def initialize(plateau_size, starting_position, instructions) @plateau_size = plateau_size @@ -13,11 +6,7 @@ class NavigateRover end def run - rover = create_plateau(@plateau_size).deploy_rover_to(@heading, @x.to_i, @y.to_i) - @instructions.each do |instruction| - eval("#{instruction.upcase}Command").new.run(rover) - end - rover.to_s + run_against(create_plateau(@plateau_size).deploy_rover_to(@heading, @x.to_i, @y.to_i)) end private @@ -26,4 +15,11 @@ class NavigateRover x,y = plateau_size.split(' ') Plateau.new(x,y) end + + def run_against(rover) + @instructions.each do |instruction| + eval("#{instruction.upcase}Command").new.run(rover) + end + rover.to_s + end end |
