class ToyRobotSim::Location
Attributes
x[R]
y[R]
Public Class Methods
new(x, y)
click to toggle source
# File lib/toy_robot_sim/location.rb, line 5 def initialize(x, y) if x.respond_to?(:to_i) && y.respond_to?(:to_i) @x = x.to_i @y = y.to_i else @x = 0 @y = 0 end end
Public Instance Methods
east()
click to toggle source
# File lib/toy_robot_sim/location.rb, line 21 def east ToyRobotSim::Location.new(x + 1, y) end
north()
click to toggle source
# File lib/toy_robot_sim/location.rb, line 17 def north ToyRobotSim::Location.new(x, y + 1) end
south()
click to toggle source
# File lib/toy_robot_sim/location.rb, line 25 def south ToyRobotSim::Location.new(x, y - 1) end
west()
click to toggle source
# File lib/toy_robot_sim/location.rb, line 29 def west ToyRobotSim::Location.new(x - 1, y) end