class PlaceCommand
Public Instance Methods
issue_command()
click to toggle source
# File lib/another_toy_robot/place_command.rb, line 8 def issue_command @target.place Position.new(x_coord: x_coord, y_coord: y_coord, direction: direction) end
post_initialize()
click to toggle source
# File lib/another_toy_robot/place_command.rb, line 4 def post_initialize @params &&= @params.join.delete(" ").split "," end
Private Instance Methods
direction()
click to toggle source
# File lib/another_toy_robot/place_command.rb, line 32 def direction case @params[2] when "n", "north" then North when "e", "east" then East when "s", "south" then South when "w", "west" then West end end
valid?()
click to toggle source
# File lib/another_toy_robot/place_command.rb, line 16 def valid? @params && @params.length == 3 && @params[0] =~ /^\d+$/ && @params[1] =~ /^\d+$/ && @params[2] =~ /^([nesw]|(north)|(east)|(south)|(west))$/ end
x_coord()
click to toggle source
# File lib/another_toy_robot/place_command.rb, line 24 def x_coord @params[0].to_i end
y_coord()
click to toggle source
# File lib/another_toy_robot/place_command.rb, line 28 def y_coord @params[1].to_i end