Class: RobotInterface::Place

Inherits:
Command
  • Object
show all
Defined in:
lib/rubbot_cli.rb

Constant Summary collapse

FORMAT =
/-?\d+,-?\d+,(NORTH|EAST|SOUTH|WEST)\s*$/mi
InvalidFormatError =
Class.new(Exception)

Constants inherited from Command

Command::NoArgumentsError

Instance Method Summary collapse

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, options = {})
  robot.place Position.new(@x, @y, @orientation)
end