Class: LittleWeasel::Preprocessors::PreprocessedWords
- Inherits:
-
Object
- Object
- LittleWeasel::Preprocessors::PreprocessedWords
- Defined in:
- lib/LittleWeasel/preprocessors/preprocessed_words.rb
Overview
This class provides a container for Preprocessors::PreprocessedWord objects.
Instance Attribute Summary collapse
-
#original_word ⇒ Object
Returns the value of attribute original_word.
-
#preprocessed_words ⇒ Object
Returns the value of attribute preprocessed_words.
Class Method Summary collapse
-
.preprocessed?(preprocessed_words:) ⇒ Boolean
Returns true if the word was passed through any preprocessing.
- .preprocessed_word(preprocessed_words:) ⇒ Object
Instance Method Summary collapse
-
#initialize(original_word:, preprocessed_words:) ⇒ PreprocessedWords
constructor
original_word:String the unsullied word before any preprocessing has been applied to it.
-
#preprocessed? ⇒ Boolean
Returns true if the word was preprocessed.
- #preprocessed_word ⇒ Object
Constructor Details
#initialize(original_word:, preprocessed_words:) ⇒ PreprocessedWords
original_word:String the unsullied word before any preprocessing has been applied to it. preprocessed_words:Array, Preprocessors::PreprocessedWord, an Array of Preprocessors::PreprocessedWord objects that represents the original_word having passed through each successive Preprocessors::WordPreprocessor.
16 17 18 19 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 16 def initialize(original_word:, preprocessed_words:) self.original_word = original_word self.preprocessed_words = preprocessed_words end |
Instance Attribute Details
#original_word ⇒ Object
Returns the value of attribute original_word.
8 9 10 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 8 def original_word @original_word end |
#preprocessed_words ⇒ Object
Returns the value of attribute preprocessed_words.
8 9 10 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 8 def preprocessed_words @preprocessed_words end |
Class Method Details
.preprocessed?(preprocessed_words:) ⇒ Boolean
Returns true if the word was passed through any preprocessing. If this is the case, #preprocessed_word may be different than #original_word.
25 26 27 28 29 30 31 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 25 def preprocessed?(preprocessed_words:) # TODO: Do we need to check for preprocessors where # #preprocessed? is true? or does preprocessed_words # contain only preprocessed word objects where # #preprocessed? is true? preprocessed_words.present? end |
.preprocessed_word(preprocessed_words:) ⇒ Object
33 34 35 36 37 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 33 def preprocessed_word(preprocessed_words:) return unless preprocessed? preprocessed_words: preprocessed_words preprocessed_words.max_by(&:preprocessor_order).preprocessed_word end |
Instance Method Details
#preprocessed? ⇒ Boolean
Returns true if the word was preprocessed
50 51 52 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 50 def preprocessed? self.class.preprocessed? preprocessed_words: preprocessed_words end |
#preprocessed_word ⇒ Object
45 46 47 |
# File 'lib/LittleWeasel/preprocessors/preprocessed_words.rb', line 45 def preprocessed_word self.class.preprocessed_word preprocessed_words: preprocessed_words end |