class RobotInterface::Place

Constants

FORMAT
InvalidFormatError

Public Class Methods

new(args) click to toggle source
Calls superclass method RobotInterface::Command::new
# 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

Public Instance Methods

execute(robot, options = {}) click to toggle source
# File lib/rubbot_cli.rb, line 23
def execute(robot, options = {})
  robot.place Position.new(@x, @y, @orientation)
end

Private Instance Methods

validate_format(argv) click to toggle source
# File lib/rubbot_cli.rb, line 29
def validate_format(argv)
  if args = argv.join(',') and args.match(FORMAT).nil?
    raise InvalidFormatError.new "'PLACE' format is invalid : '#{args}'"
  end
end