Class: Crucigrama::GrillBuilder
- Inherits:
-
CrosswordBuilder
- Object
- CrosswordBuilder
- Crucigrama::GrillBuilder
- Defined in:
- lib/crucigrama/grill_builder.rb
Constant Summary
Constants inherited from CrosswordBuilder
CrosswordBuilder::NOT_REPEATABLE_WORD_MINIMUM_LENGTH
Instance Attribute Summary collapse
-
#grill_spacing ⇒ Object
readonly
Returns the value of attribute grill_spacing.
Attributes inherited from CrosswordBuilder
#crossword, #crossword_class, #valid_words
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(opts = {}) ⇒ GrillBuilder
constructor
A new instance of GrillBuilder.
Methods inherited from CrosswordBuilder
#adyacent_words_to_position, build_crossword, #can_be_set_condition, #not_word_destructive_condition, #set_longest_word_at, #transversal_conditions_for, #used_words, #valid_word?, #valid_words_by_length, #validate
Methods included from Positionable
#direction_other_than, #position
Constructor Details
#initialize(opts = {}) ⇒ GrillBuilder
Returns a new instance of GrillBuilder.
5 6 7 8 |
# File 'lib/crucigrama/grill_builder.rb', line 5 def initialize(opts = {}) @grill_spacing = opts.delete(:grill_spacing) || 2 super(opts) end |
Instance Attribute Details
#grill_spacing ⇒ Object (readonly)
Returns the value of attribute grill_spacing.
3 4 5 |
# File 'lib/crucigrama/grill_builder.rb', line 3 def grill_spacing @grill_spacing end |
Instance Method Details
#build ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/crucigrama/grill_builder.rb', line 10 def build grill_spacing.times do |i| (i..crossword.dimensions.values.max-1).step(grill_spacing).each do |coordinate| fill_line(coordinate,:horizontal) if crossword.dimensions[:horizontal] > coordinate fill_line(coordinate,:vertical) if crossword.dimensions[:vertical] > coordinate end end crossword end |