Class: Conway::Generation

Inherits:
Object
  • Object
show all
Defined in:
lib/conway/generation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_lookupObject

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_coordinatesObject



16
17
18
# File 'lib/conway/generation.rb', line 16

def cell_coordinates
  location_lookup.locations.map {|loc| loc.point }
end

#nextObject



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