Class: RubyRobot::Shell
- Inherits:
-
Bombshell::Environment
- Object
- Bombshell::Environment
- RubyRobot::Shell
show all
- Includes:
- Bombshell::Shell
- Defined in:
- lib/ruby_robot/shell.rb
Constant Summary
Bombshell::Shell::EAST, Bombshell::Shell::NORTH, Bombshell::Shell::REMOVE, Bombshell::Shell::SOUTH, Bombshell::Shell::WEST
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Shell
16
17
18
19
20
21
|
# File 'lib/ruby_robot/shell.rb', line 16
def initialize
@logger = Logger.new(STDOUT)
@logger.formatter = proc { |severity, datetime, progname, msg|
"#{msg}\n"
}
end
|
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
14
15
16
|
# File 'lib/ruby_robot/shell.rb', line 14
def logger
@logger
end
|
Instance Method Details
#LEFT ⇒ Object
50
51
52
53
|
# File 'lib/ruby_robot/shell.rb', line 50
def LEFT
return if @robot.nil?
@robot.left
end
|
#MOVE ⇒ Object
45
46
47
48
|
# File 'lib/ruby_robot/shell.rb', line 45
def MOVE
return if @robot.nil?
@robot.move
end
|
#PLACE(x, y, direction) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/ruby_robot/shell.rb', line 26
def PLACE(x, y, direction)
orig_robot = @robot
orig_tabletop = @tabletop
@robot = Robot.new(direction)
@tabletop = NetflixTabletop.new
begin
@tabletop.place(@robot, x: x, y: y)
true
rescue
@robot = orig_robot
@tabletop = orig_tabletop
@logger.info $!
false
end
end
|
#REPORT(to_stderr = true) ⇒ Object
60
61
62
63
64
|
# File 'lib/ruby_robot/shell.rb', line 60
def REPORT(to_stderr=true)
return nil if @robot.nil?
@logger.info(@robot.report) if to_stderr
@robot.report
end
|
#RIGHT ⇒ Object
55
56
57
58
|
# File 'lib/ruby_robot/shell.rb', line 55
def RIGHT
return if @robot.nil?
@robot.right
end
|