class Controller
Controls rover by passing instructions and requesting position data
Public Class Methods
new(rover)
click to toggle source
# File lib/controller.rb, line 5 def initialize(rover) @rover = rover end
Public Instance Methods
destination()
click to toggle source
# File lib/controller.rb, line 23 def destination @rover.to_s end
process_instructions(instructions)
click to toggle source
# File lib/controller.rb, line 9 def process_instructions(instructions) instruction_array = instructions.split('') instruction_array.each do |item| case item when 'L' @rover.turn_left when 'R' @rover.turn_right when 'M' @rover.move end end end