Commit eb04ff7
Changed files (3)
spec
features
step_definitions
lib/command_processor.rb
@@ -7,7 +7,7 @@ class CommandProcessor
end
def run
while @commands.length > 0 do
- puts @commands.shift.run
+ @commands.shift.run
end
end
end
lib/console.rb
@@ -11,11 +11,10 @@ class Console
plateau = ask('enter size of plateau:')
while ((landing = ask('enter landing coordinate (q to quit):')) != 'q') do
- command = NavigateRover.new(plateau, landing, ask('enter instructions:'))
- @processor.add(command)
+ @processor.add(create_command_for(plateau, landing))
end
- @output.puts "#{@processor.run}"
+ @processor.run
end
private
@@ -25,4 +24,18 @@ class Console
@output.print '> '
@input.gets.chomp!
end
+
+ def create_command_for(plateau, landing)
+ OutputResult.new(NavigateRover.new(plateau, landing, ask('enter instructions:')), @output)
+ end
+end
+
+class OutputResult
+ def initialize(command, output)
+ @command = command
+ @output = output
+ end
+ def run
+ @output.puts "#{@command.run}"
+ end
end