Class: Cell
- Inherits:
-
Object
- Object
- Cell
- Defined in:
- lib/golife.rb
Instance Attribute Summary collapse
-
#alive ⇒ Object
Returns the value of attribute alive.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #dead! ⇒ Object
- #dead? ⇒ Boolean
-
#initialize(x, y, alive = false) ⇒ Cell
constructor
A new instance of Cell.
- #live! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(x, y, alive = false) ⇒ Cell
Returns a new instance of Cell.
81 82 83 84 85 |
# File 'lib/golife.rb', line 81 def initialize(x, y, alive = false) self.x = x self.y = y self.alive = alive end |
Instance Attribute Details
#alive ⇒ Object
Returns the value of attribute alive.
79 80 81 |
# File 'lib/golife.rb', line 79 def alive @alive end |
#x ⇒ Object
Returns the value of attribute x.
79 80 81 |
# File 'lib/golife.rb', line 79 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
79 80 81 |
# File 'lib/golife.rb', line 79 def y @y end |
Instance Method Details
#alive? ⇒ Boolean
87 88 89 |
# File 'lib/golife.rb', line 87 def alive? @alive end |
#dead! ⇒ Object
95 96 97 98 |
# File 'lib/golife.rb', line 95 def dead! @alive = false self end |
#dead? ⇒ Boolean
91 92 93 |
# File 'lib/golife.rb', line 91 def dead? !@alive end |
#live! ⇒ Object
100 101 102 103 |
# File 'lib/golife.rb', line 100 def live! @alive = true self end |
#to_s ⇒ Object
105 106 107 |
# File 'lib/golife.rb', line 105 def to_s "x: #{@x}, y: #{@y}" end |