class Rchess::Coord
Attributes
x[RW]
y[RW]
Public Class Methods
new(h)
click to toggle source
# File lib/rchess/coord.rb, line 5 def initialize(h) self.x = h.fetch(:x){ raise ArgumentError.new("Please provide a value for key :x") } self.y = h.fetch(:y){ raise ArgumentError.new("Please provide a value for key :y") } end
Public Instance Methods
apply_delta(delta)
click to toggle source
# File lib/rchess/coord.rb, line 10 def apply_delta(delta) Coord.new({ x: (self.x + delta[:x]), y: (self.y + delta[:y]) }) end
to_hash()
click to toggle source
# File lib/rchess/coord.rb, line 14 def to_hash { x: self.x, y: self.y } end