class MauxRobot::CLI
The CLI
is a class responsible of handling command line interface
Attributes
robot[R]
Public Class Methods
new()
click to toggle source
# File lib/maux_robot/cli.rb, line 7 def initialize @robot = Robot.new end
Public Instance Methods
execute(command)
click to toggle source
# File lib/maux_robot/cli.rb, line 31 def execute(command) if command.key?(:arguments) @robot.send(command[:order], command[:arguments]) else @robot.send(command[:order]) end end
parse(line_input)
click to toggle source
# File lib/maux_robot/cli.rb, line 27 def parse(line_input) Parser.new.parse(line_input) end
run()
click to toggle source
Receives everything from standard input and executes
# File lib/maux_robot/cli.rb, line 12 def run run_script(STDIN.read) end
run_script(all_input)
click to toggle source
# File lib/maux_robot/cli.rb, line 16 def run_script(all_input) all_input.split("\n").each do |line_input| command = parse(line_input) begin execute(command) if command rescue MauxRobot::RobotError => e puts e if @robot.talkative end end end