Class: WordSearch::PositionWord::Base
- Inherits:
-
Object
- Object
- WordSearch::PositionWord::Base
- Defined in:
- lib/word_search/position_word/base.rb
Instance Attribute Summary collapse
-
#coordinate ⇒ Object
Returns the value of attribute coordinate.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#plane ⇒ Object
Returns the value of attribute plane.
-
#positions ⇒ Object
Returns the value of attribute positions.
-
#word ⇒ Object
Returns the value of attribute word.
Instance Method Summary collapse
- #document_position ⇒ Object
-
#initialize(plane, word, direction, coordinate) ⇒ Base
constructor
A new instance of Base.
- #last_coordinates_in_plane? ⇒ Boolean
- #letter_at ⇒ Object
- #perform ⇒ Object
- #place_letter ⇒ Object
- #positive_last_coordinates? ⇒ Boolean
- #update_coordinates ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(plane, word, direction, coordinate) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 |
# File 'lib/word_search/position_word/base.rb', line 8 def initialize(plane, word, direction, coordinate) @plane = plane @word = word @direction = direction @coordinate = coordinate @positions = {} end |
Instance Attribute Details
#coordinate ⇒ Object
Returns the value of attribute coordinate.
6 7 8 |
# File 'lib/word_search/position_word/base.rb', line 6 def coordinate @coordinate end |
#direction ⇒ Object
Returns the value of attribute direction.
6 7 8 |
# File 'lib/word_search/position_word/base.rb', line 6 def direction @direction end |
#plane ⇒ Object
Returns the value of attribute plane.
6 7 8 |
# File 'lib/word_search/position_word/base.rb', line 6 def plane @plane end |
#positions ⇒ Object
Returns the value of attribute positions.
6 7 8 |
# File 'lib/word_search/position_word/base.rb', line 6 def positions @positions end |
#word ⇒ Object
Returns the value of attribute word.
6 7 8 |
# File 'lib/word_search/position_word/base.rb', line 6 def word @word end |
Instance Method Details
#document_position ⇒ Object
52 53 54 |
# File 'lib/word_search/position_word/base.rb', line 52 def document_position raise NotImplementedError end |
#last_coordinates_in_plane? ⇒ Boolean
44 45 46 |
# File 'lib/word_search/position_word/base.rb', line 44 def last_coordinates_in_plane? raise NotImplementedError end |
#letter_at ⇒ Object
48 49 50 |
# File 'lib/word_search/position_word/base.rb', line 48 def letter_at raise NotImplementedError end |
#perform ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/word_search/position_word/base.rb', line 16 def perform return false unless valid? letters.each_with_index do |letter, index| place_letter(letter) document_position(letter, index) update_coordinates end positions end |
#place_letter ⇒ Object
32 33 34 |
# File 'lib/word_search/position_word/base.rb', line 32 def place_letter raise NotImplementedError end |
#positive_last_coordinates? ⇒ Boolean
40 41 42 |
# File 'lib/word_search/position_word/base.rb', line 40 def positive_last_coordinates? raise NotImplementedError end |
#update_coordinates ⇒ Object
36 37 38 |
# File 'lib/word_search/position_word/base.rb', line 36 def update_coordinates raise NotImplementedError end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/word_search/position_word/base.rb', line 28 def valid? valid_coordinates? && valid_letters? end |