class Robotoy::Services::Orientation

Public Class Methods

new(robot:, side:) click to toggle source
# File lib/robotoy/services/orientation.rb, line 4
def initialize(robot:, side:)
  @robot = robot
  @side = side
  order_orients
end

Public Instance Methods

perform() click to toggle source
# File lib/robotoy/services/orientation.rb, line 10
def perform
  send(@side)
end

Private Instance Methods

left() click to toggle source
# File lib/robotoy/services/orientation.rb, line 20
def left
  @robot.orientation = @robot.orients.rotate(-1)[0]
end
order_orients() click to toggle source
# File lib/robotoy/services/orientation.rb, line 24
def order_orients
  return unless @robot.orientation
  index = @robot.orients.index(@robot.orientation)
  @robot.orients.rotate!(index)
end
right() click to toggle source
# File lib/robotoy/services/orientation.rb, line 16
def right
  @robot.orientation = @robot.orients.rotate[0]
end