Class: GridBuilder
- Inherits:
-
Object
- Object
- GridBuilder
- Defined in:
- lib/generate_game.rb
Instance Attribute Summary collapse
-
#grid_size ⇒ Object
readonly
Returns the value of attribute grid_size.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #create_grid ⇒ Object
-
#initialize(grid_size, initial_state = []) ⇒ GridBuilder
constructor
A new instance of GridBuilder.
Constructor Details
#initialize(grid_size, initial_state = []) ⇒ GridBuilder
Returns a new instance of GridBuilder.
5 6 7 8 |
# File 'lib/generate_game.rb', line 5 def initialize(grid_size, initial_state = []) @grid_size = grid_size @state = initial_state end |
Instance Attribute Details
#grid_size ⇒ Object (readonly)
Returns the value of attribute grid_size.
4 5 6 |
# File 'lib/generate_game.rb', line 4 def grid_size @grid_size end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
4 5 6 |
# File 'lib/generate_game.rb', line 4 def state @state end |
Instance Method Details
#create_grid ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/generate_game.rb', line 10 def create_grid grid_size.times do state << [] end state.each do |row| grid_size.times { row << Cell.new } end end |