module TresBot
Constants
- VERSION
Public Class Methods
execute_command(robot,command)
click to toggle source
# File lib/tres_bot.rb, line 72 def self.execute_command(robot,command) @robot = robot command = command.split(' ') if command[0] != nil if command[0].downcase == 'place' if place_command_valid?(command) full_position = command[1].split(',') @robot.place(full_position) else puts "Your place command is invalid. Please try again." end elsif ['move', 'report','left','right'].include? command[0].downcase @robot.is_on_the_table ? @robot.send(command[0].downcase) : (puts "Put me on the table!") end end end
place_command_valid?(command)
click to toggle source
# File lib/tres_bot.rb, line 64 def self.place_command_valid?(command) if command[1].nil? return false else command[1].downcase.gsub(/\s+/, "").match(/[0-4]+[,]+[0-9]+[,]+[a-z]{4,5}/) ? true : false end end
start()
click to toggle source
# File lib/tres_bot.rb, line 90 def self.start puts 'Press Ctrl-C to exit' @robot = Robot.new until false == true command = gets execute_command(@robot,command) end end