Class: Cell
- Inherits:
-
Object
- Object
- Cell
- Defined in:
- lib/cell.rb
Overview
Population
Constant Summary collapse
- DEAD =
' '
- ALIVE =
'█'
Instance Attribute Summary collapse
-
#coordinates ⇒ Object
readonly
Returns the value of attribute coordinates.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #dead? ⇒ Boolean
-
#initialize(state, *coordinates) ⇒ Cell
constructor
A new instance of Cell.
- #n_indices ⇒ Object
- #next_gen_fate(live_ncells) ⇒ Object
Constructor Details
#initialize(state, *coordinates) ⇒ Cell
Returns a new instance of Cell.
9 10 11 12 13 |
# File 'lib/cell.rb', line 9 def initialize(state, *coordinates) @coordinates = coordinates @state = state n_indices end |
Instance Attribute Details
#coordinates ⇒ Object (readonly)
Returns the value of attribute coordinates.
7 8 9 |
# File 'lib/cell.rb', line 7 def coordinates @coordinates end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/cell.rb', line 7 def state @state end |
Instance Method Details
#n_indices ⇒ Object
15 16 17 |
# File 'lib/cell.rb', line 15 def n_indices @n_indices ||= neighbor_indices end |