Sha256: 6022f6b23e552e6986e79b8269f62b22a499329b9bd6047c72740b7ee83c026d
Contents?: true
Size: 583 Bytes
Versions: 2
Compression:
Stored size: 583 Bytes
Contents
# Point value object module Robot class Point attr_reader :x, :y def initialize(x:, y:) @x = x @y = y end def north Point.new(x: x, y: y + 1) end def south Point.new(x: x, y: y - 1) end def east Point.new(x: x + 1, y: y) end def west Point.new(x: x - 1, y: y) end def ==(point) x == point.x && y == point.y end def >(point) x > point.x || y > point.y end def <(point) x < point.x || y < point.y end def to_s "#{x}, #{y}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
robot_rea-0.1.5 | lib/robot/point.rb |
robot_rea-0.1.4 | lib/robot/point.rb |