Class: Boggler::Grid
- Inherits:
-
Object
- Object
- Boggler::Grid
- Defined in:
- lib/boggler/grid.rb
Instance Method Summary collapse
-
#initialize ⇒ Grid
constructor
A new instance of Grid.
- #to_s ⇒ Object
- #words ⇒ Object
Constructor Details
Instance Method Details
#to_s ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/boggler/grid.rb', line 12 def to_s row_strings = [] @grid.each do |row| row_strings << row_string_for(row) end grid_string = separator row_strings.each do |row| grid_string += row grid_string += separator end grid_string end |
#words ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/boggler/grid.rb', line 28 def words return @words if defined?(@words) @words = [] @size.times do |i| @size.times do |j| words_starting_at(i + 1, j + 1) end end @words end |