Class: Conway::Generation
- Inherits:
-
Object
- Object
- Conway::Generation
- Defined in:
- lib/conway/generation.rb
Instance Attribute Summary collapse
-
#location_lookup ⇒ Object
readonly
Returns the value of attribute location_lookup.
Instance Method Summary collapse
- #cell_coordinates ⇒ Object
-
#initialize(points_or_lookup, rules = Rules.new) ⇒ Generation
constructor
A new instance of Generation.
- #next ⇒ Object
Constructor Details
#initialize(points_or_lookup, rules = Rules.new) ⇒ Generation
Returns a new instance of Generation.
5 6 7 8 |
# File 'lib/conway/generation.rb', line 5 def initialize(points_or_lookup, rules=Rules.new) self.location_lookup = normalize_to_lookup points_or_lookup self.rules = rules end |
Instance Attribute Details
#location_lookup ⇒ Object
Returns the value of attribute location_lookup.
3 4 5 |
# File 'lib/conway/generation.rb', line 3 def location_lookup @location_lookup end |
Instance Method Details
#cell_coordinates ⇒ Object
16 17 18 |
# File 'lib/conway/generation.rb', line 16 def cell_coordinates location_lookup.locations.map {|loc| loc.point } end |
#next ⇒ Object
10 11 12 13 14 |
# File 'lib/conway/generation.rb', line 10 def next cell_space = CellSpace.new(location_lookup.locations) cell_lookup = cell_space.apply(rules) Generation.new cell_lookup, rules end |