class Toy::Unit

Attributes

object[R]
table[R]
x[R]
y[R]

Public Class Methods

new(x, y, table=Toy::Table.new) click to toggle source
# File lib/toy/unit.rb, line 7
def initialize(x, y, table=Toy::Table.new)
  raise Toy::Unit::Error::CoordinateError unless x.is_a?(Fixnum)
  raise Toy::Unit::Error::CoordinateError unless y.is_a?(Fixnum)
  raise Toy::Unit::Error::TableError unless table.is_a?(Table)

  @table = table
  @x = x
  @y = y
  @object = nil
end

Public Instance Methods

available?() click to toggle source
# File lib/toy/unit.rb, line 26
def available?
  @object.nil?
end
hold!(object) click to toggle source
# File lib/toy/unit.rb, line 18
def hold!(object)
  @object = object
end
release!() click to toggle source
# File lib/toy/unit.rb, line 22
def release!
  @object = nil
end