Class: Vida::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/vida/game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#gridObject (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_generationObject



17
18
19
# File 'lib/vida/game.rb', line 17

def next_generation
  grid.update_cells
end

#playObject



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