class Battleship::Coord
Attributes
x[R]
y[R]
Public Class Methods
factory(data)
click to toggle source
# File lib/battleship/coord.rb, line 11 def self.factory(data) new(*data.split(" ")) rescue ArgumentError fail FactoryError.new("coordinate must be specified as 'x y' (ie 1 2)") end
new(x, y)
click to toggle source
# File lib/battleship/coord.rb, line 17 def initialize(x, y) @x = x.to_i.abs @y = y.to_i.abs end
orig()
click to toggle source
# File lib/battleship/coord.rb, line 7 def self.orig @orig ||= new(0, 0) end
Public Instance Methods
<=(other)
click to toggle source
# File lib/battleship/coord.rb, line 30 def <=(other) x <= other.x && y <= other.y end
==(other)
click to toggle source
# File lib/battleship/coord.rb, line 34 def ==(other) x == other.x && y == other.y end
>=(other)
click to toggle source
# File lib/battleship/coord.rb, line 26 def >=(other) x >= other.x && y >= other.y end
to_s()
click to toggle source
# File lib/battleship/coord.rb, line 22 def to_s "#{x} #{y}" end