Class: RobotInterface::Place
Constant Summary collapse
- FORMAT =
/-?\d+,-?\d+,(NORTH|EAST|SOUTH|WEST)\s*$/mi
- InvalidFormatError =
Class.new(Exception)
Constants inherited from Command
Instance Method Summary collapse
- #execute(robot, options = {}) ⇒ Object
-
#initialize(args) ⇒ Place
constructor
A new instance of Place.
Constructor Details
#initialize(args) ⇒ Place
Returns a new instance of Place.
15 16 17 18 19 20 21 |
# File 'lib/rubbot_cli.rb', line 15 def initialize(args) super validate_format args @x = args.shift.to_i @y = args.shift.to_i @orientation = Position.const_get(args.shift.upcase) end |
Instance Method Details
#execute(robot, options = {}) ⇒ Object
23 24 25 |
# File 'lib/rubbot_cli.rb', line 23 def execute(robot, = {}) robot.place Position.new(@x, @y, @orientation) end |