Module: Amaze::MaskedGrid
- Defined in:
- lib/amaze/masked_grid.rb
Instance Attribute Summary collapse
-
#mask ⇒ Object
readonly
The mask.
Instance Method Summary collapse
Instance Attribute Details
#mask ⇒ Object (readonly)
The mask
5 6 7 |
# File 'lib/amaze/masked_grid.rb', line 5 def mask @mask end |
Instance Method Details
#initialize(mask) ⇒ Object
7 8 9 10 |
# File 'lib/amaze/masked_grid.rb', line 7 def initialize mask @mask = mask super mask.rows, mask.columns end |
#prepare_grid ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/amaze/masked_grid.rb', line 12 def prepare_grid super each_cell do |cell| row, column = cell.row, cell.column grid[row][column] = nil unless mask[row, column] end end |
#random_cell ⇒ Object
21 22 23 24 |
# File 'lib/amaze/masked_grid.rb', line 21 def random_cell row, column = mask.random_location self[row, column] end |
#size ⇒ Object
26 27 28 |
# File 'lib/amaze/masked_grid.rb', line 26 def size mask.count end |