Class: Lifelike::LifelikeCellularAutomaton::Cell
- Inherits:
-
Object
- Object
- Lifelike::LifelikeCellularAutomaton::Cell
- Defined in:
- lib/lifelike/lifelike_cellular_automaton/cell.rb
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(alive, rules) ⇒ Cell
constructor
A new instance of Cell.
- #tick(neighbors) ⇒ Object
Constructor Details
#initialize(alive, rules) ⇒ Cell
Returns a new instance of Cell.
4 5 6 7 |
# File 'lib/lifelike/lifelike_cellular_automaton/cell.rb', line 4 def initialize(alive, rules) @alive = alive @rules = rules end |
Instance Method Details
#alive? ⇒ Boolean
9 10 11 |
# File 'lib/lifelike/lifelike_cellular_automaton/cell.rb', line 9 def alive? @alive end |
#tick(neighbors) ⇒ Object
13 14 15 16 |
# File 'lib/lifelike/lifelike_cellular_automaton/cell.rb', line 13 def tick(neighbors) @neighbors = neighbors self.class.new(alive_next?, @rules) end |