Module: Commands
- Defined in:
- lib/rubbot_cli.rb
Constant Summary collapse
- COMMANDS_MAP =
Map input instructions to Robot actions
{ "PLACE" => RobotInterface::Place, "MOVE" => RobotInterface::Move, "LEFT" => RobotInterface::Left, "RIGHT" => RobotInterface::Right, "REPORT" => RobotInterface::Report, "HELP" => RobotInterface::Help }
- NoCommandError =
Class.new(Exception)
Class Method Summary collapse
Class Method Details
.parse(input) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/rubbot_cli.rb', line 91 def self.parse(input) cmd, args = input.split args = String(args).split(",") cmd_class = COMMANDS_MAP[String(cmd).upcase] raise NoCommandError.new "'#{cmd}'' is undefined." unless cmd_class cmd_class.new args end |