class Robot::Point

Attributes

x[R]
y[R]

Public Class Methods

new(x:, y:) click to toggle source
# File lib/robot/point.rb, line 9
def initialize(x:, y:)
  @x = x
  @y = y
end

Public Instance Methods

<(other) click to toggle source
# File lib/robot/point.rb, line 38
def <(other)
  x < other.x || y < other.y
end
==(other) click to toggle source
# File lib/robot/point.rb, line 30
def ==(other)
  x == other.x && y == other.y
end
>(other) click to toggle source
# File lib/robot/point.rb, line 34
def >(other)
  x > other.x || y > other.y
end
east() click to toggle source
# File lib/robot/point.rb, line 22
def east
  Point.new(x: x + 1, y: y)
end
north() click to toggle source
# File lib/robot/point.rb, line 14
def north
  Point.new(x: x, y: y + 1)
end
south() click to toggle source
# File lib/robot/point.rb, line 18
def south
  Point.new(x: x, y: y - 1)
end
to_s() click to toggle source
# File lib/robot/point.rb, line 42
def to_s
  "#{x}, #{y}"
end
west() click to toggle source
# File lib/robot/point.rb, line 26
def west
  Point.new(x: x - 1, y: y)
end