lib/robot/position.rb in robot_rea-0.1.5 vs lib/robot/position.rb in robot_rea-0.1.6

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + # Position value object module Robot class Position attr_reader :point, :direction @@ -24,43 +26,41 @@ def west Position.new(point: point.west, direction: direction) end def left - Position.new(point: point, direction: lefts[direction] ) + Position.new(point: point, direction: lefts[direction]) end def right - Position.new(point: point, direction: rights[direction] ) + Position.new(point: point, direction: rights[direction]) end - def ==(position) - point == position.point && direction == position.direction + def ==(other) + point == other.point && direction == other.direction end def to_s "#{point}, #{direction}" end private def lefts { - Robot::Directions::EAST => Robot::Directions::NORTH, + Robot::Directions::EAST => Robot::Directions::NORTH, Robot::Directions::NORTH => Robot::Directions::WEST, - Robot::Directions::WEST => Robot::Directions::SOUTH, - Robot::Directions::SOUTH => Robot::Directions::EAST, + Robot::Directions::WEST => Robot::Directions::SOUTH, + Robot::Directions::SOUTH => Robot::Directions::EAST }.freeze end def rights { - Robot::Directions::EAST => Robot::Directions::SOUTH, + Robot::Directions::EAST => Robot::Directions::SOUTH, Robot::Directions::SOUTH => Robot::Directions::WEST, - Robot::Directions::WEST => Robot::Directions::NORTH, - Robot::Directions::NORTH => Robot::Directions::EAST, + Robot::Directions::WEST => Robot::Directions::NORTH, + Robot::Directions::NORTH => Robot::Directions::EAST }.freeze end end end - -