Class: Robulator::Tabletop

Inherits:
Object
  • Object
show all
Defined in:
lib/robulator/tabletop.rb

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ Tabletop

Returns a new instance of Tabletop.



3
4
5
6
# File 'lib/robulator/tabletop.rb', line 3

def initialize(size)
  size             = Integer(size)
  @placeable_spots = {x: 0...size, y: 0...size}
end

Instance Method Details

#placeable_spot?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
# File 'lib/robulator/tabletop.rb', line 8

def placeable_spot?(x, y)
  @placeable_spots[:x].include?(Integer(x)) &&
  @placeable_spots[:y].include?(Integer(y))
rescue ArgumentError
  false
end