Class: Vida::Game
- Inherits:
-
Object
- Object
- Vida::Game
- Defined in:
- lib/vida/game.rb
Instance Attribute Summary collapse
-
#grid ⇒ Object
readonly
Returns the value of attribute grid.
Instance Method Summary collapse
-
#initialize(grid) ⇒ Game
constructor
A new instance of Game.
- #next_generation ⇒ Object
- #play ⇒ Object
Constructor Details
#initialize(grid) ⇒ Game
Returns a new instance of Game.
4 5 6 |
# File 'lib/vida/game.rb', line 4 def initialize(grid) @grid = grid end |
Instance Attribute Details
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
2 3 4 |
# File 'lib/vida/game.rb', line 2 def grid @grid end |
Instance Method Details
#next_generation ⇒ Object
17 18 19 |
# File 'lib/vida/game.rb', line 17 def next_generation grid.update_cells end |
#play ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/vida/game.rb', line 8 def play loop do next_generation system('clear') puts grid sleep(0.05) end end |