Class: SlackGame::Game::Lifegame::Field
- Inherits:
-
Object
- Object
- SlackGame::Game::Lifegame::Field
- Defined in:
- lib/slack_game/game/lifegame.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Instance Method Summary collapse
-
#initialize(size) ⇒ Field
constructor
A new instance of Field.
- #next ⇒ Object
- #to_display ⇒ Object
Constructor Details
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
30 31 32 |
# File 'lib/slack_game/game/lifegame.rb', line 30 def field @field end |
Instance Method Details
#next ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/slack_game/game/lifegame.rb', line 36 def next next_field = Array.new(@size) { Array.new(@size) } @field.each_with_index do |line, outer_index| line.each_with_index do |cell, inner_index| next_field[outer_index][inner_index] = cell.next_gen(arround_cells(outer_index, inner_index)) end end @field = next_field self end |