class Robotoy::Game
Public Class Methods
new(robot: Robot.new, table: Table.new, move: Services::Move, place: Services::Place, orientation: Services::Orientation, report: Services::Report)
click to toggle source
# File lib/robotoy/game.rb, line 3 def initialize(robot: Robot.new, table: Table.new, move: Services::Move, place: Services::Place, orientation: Services::Orientation, report: Services::Report) @robot = robot @table = table @move = move @place = place @orientation = orientation @report = report end
Public Instance Methods
perform(method, *args)
click to toggle source
# File lib/robotoy/game.rb, line 12 def perform(method, *args) send(method.downcase, *args.flatten) end
Private Instance Methods
left()
click to toggle source
# File lib/robotoy/game.rb, line 26 def left @orientation.new(robot: @robot, side: :left).perform end
method_missing(_name, *_args)
click to toggle source
# File lib/robotoy/game.rb, line 38 def method_missing(_name, *_args) raise Robotoy::NotValidMethodError end
move(range = 1)
click to toggle source
# File lib/robotoy/game.rb, line 22 def move(range = 1) @move.new(robot: @robot, table: @table, range: range).perform end
place(x, y, orient)
click to toggle source
# File lib/robotoy/game.rb, line 18 def place(x, y, orient) @place.new(robot: @robot, table: @table, x: x, y: y, orient: orient).perform end
report(type = :console)
click to toggle source
# File lib/robotoy/game.rb, line 34 def report(type = :console) @report.new(robot: @robot, type: type).perform end
right()
click to toggle source
# File lib/robotoy/game.rb, line 30 def right @orientation.new(robot: @robot, side: :right).perform end