Class: Conway::PotentialCellCollection
- Inherits:
-
Object
- Object
- Conway::PotentialCellCollection
- Includes:
- MemoizedCells
- Defined in:
- lib/conway/potential_cell_collection.rb
Instance Method Summary collapse
- #each_location(&block) ⇒ Object
-
#initialize(live_locations) ⇒ PotentialCellCollection
constructor
A new instance of PotentialCellCollection.
Methods included from MemoizedCells
Constructor Details
#initialize(live_locations) ⇒ PotentialCellCollection
Returns a new instance of PotentialCellCollection.
5 6 7 8 9 10 11 |
# File 'lib/conway/potential_cell_collection.rb', line 5 def initialize(live_locations) self.potential_cell_lookup = CellLocationLookup.new do |point| CellLocation.new(dead_cell, point) end insert_potential_locations(live_locations) end |
Instance Method Details
#each_location(&block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/conway/potential_cell_collection.rb', line 13 def each_location(&block) potential_cell_lookup.each do |cell_location| neighbor_locations = neighbors_for(cell_location) block.call(cell_location, neighbor_locations) end end |