class Robot
Attributes
arena[RW]
position[R]
Public Class Methods
new(position: NullPosition.new, arena: NullArena.new)
click to toggle source
# File lib/another_toy_robot/robot.rb, line 10 def initialize(position: NullPosition.new, arena: NullArena.new) @position = position @arena = arena end
Public Instance Methods
left()
click to toggle source
# File lib/another_toy_robot/robot.rb, line 23 def left safely_go_to @position.left end
move()
click to toggle source
# File lib/another_toy_robot/robot.rb, line 19 def move safely_go_to @position.advance end
place(position)
click to toggle source
# File lib/another_toy_robot/robot.rb, line 15 def place(position) safely_go_to position end
report()
click to toggle source
# File lib/another_toy_robot/robot.rb, line 31 def report puts @position.to_s end
right()
click to toggle source
# File lib/another_toy_robot/robot.rb, line 27 def right safely_go_to @position.right end
Private Instance Methods
safely_go_to(position)
click to toggle source
# File lib/another_toy_robot/robot.rb, line 37 def safely_go_to(position) return unless @arena.inbounds? position @position = position end