Class: LocoBot::CLI::Command::Place

Inherits:
Base
  • Object
show all
Defined in:
lib/loco_bot/cli/command/place.rb

Overview

Upon execution, calls #place on the robot attribute.

Instance Attribute Summary

Attributes inherited from Base

#robot, #table

Instance Method Summary collapse

Methods inherited from Base

#initialize, label

Constructor Details

This class inherits a constructor from LocoBot::CLI::Command::Base

Instance Method Details

#execute(x, y, direction_name) ⇒ Boolean

Executes the command. Calls #place on the robot attribute, passing the table attribute and the given arguments.

Returns:

  • (Boolean)

    true if the operation succeeded, false otherwise.



9
10
11
12
13
# File 'lib/loco_bot/cli/command/place.rb', line 9

def execute(x, y, direction_name)
  direction = Robot::Direction.from_name(direction_name)

  robot.place(table, x.to_i, y.to_i, direction)
end