class Robot::CommandCentre::Command
Attributes
args[R]
command[R]
robot[R]
Public Class Methods
new(command_string)
click to toggle source
# File lib/robot/command_centre.rb, line 26 def initialize(command_string) @command, @args = command_string.split(' ') @robot = Robot.instance end
Public Instance Methods
execute()
click to toggle source
# File lib/robot/command_centre.rb, line 31 def execute return robot.place(args) if place? return robot.send(:"#{command.downcase}") if robot.table.placed? CommandCentre.instance.say('Does not compute, You must place me first') end
place?()
click to toggle source
# File lib/robot/command_centre.rb, line 37 def place? command == 'PLACE' end
validate()
click to toggle source
# File lib/robot/command_centre.rb, line 41 def validate COMMANDS.include?(command) end