Class: GameOfLife::Cell
- Inherits:
-
Object
- Object
- GameOfLife::Cell
- Defined in:
- lib/game-of-life/cell.rb
Instance Attribute Summary collapse
-
#alive ⇒ Object
Returns the value of attribute alive.
-
#neighbours ⇒ Object
Returns the value of attribute neighbours.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #==(otherCell) ⇒ Object
- #alive? ⇒ Boolean
- #dead? ⇒ Boolean
- #die! ⇒ Object
-
#initialize(x = 0, y = 0, alive = true) ⇒ Cell
constructor
A new instance of Cell.
- #reborn! ⇒ Object
Constructor Details
#initialize(x = 0, y = 0, alive = true) ⇒ Cell
Returns a new instance of Cell.
4 5 6 7 |
# File 'lib/game-of-life/cell.rb', line 4 def initialize(x=0,y=0,alive=true) @x,@y = x,y @alive = alive end |
Instance Attribute Details
#alive ⇒ Object
Returns the value of attribute alive.
3 4 5 |
# File 'lib/game-of-life/cell.rb', line 3 def alive @alive end |
#neighbours ⇒ Object
Returns the value of attribute neighbours.
3 4 5 |
# File 'lib/game-of-life/cell.rb', line 3 def neighbours @neighbours end |
#x ⇒ Object
Returns the value of attribute x.
3 4 5 |
# File 'lib/game-of-life/cell.rb', line 3 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
3 4 5 |
# File 'lib/game-of-life/cell.rb', line 3 def y @y end |
Instance Method Details
#==(otherCell) ⇒ Object
9 10 11 |
# File 'lib/game-of-life/cell.rb', line 9 def ==(otherCell) (self.x == otherCell.x) and (self.y == otherCell.y) end |
#alive? ⇒ Boolean
17 18 19 |
# File 'lib/game-of-life/cell.rb', line 17 def alive? self.alive end |
#dead? ⇒ Boolean
21 22 23 |
# File 'lib/game-of-life/cell.rb', line 21 def dead? not alive? end |
#die! ⇒ Object
29 30 31 |
# File 'lib/game-of-life/cell.rb', line 29 def die! @alive = false end |
#reborn! ⇒ Object
25 26 27 |
# File 'lib/game-of-life/cell.rb', line 25 def reborn! @alive = true end |