class LittleWeasel::Preprocessors::PreprocessedWords

This class provides a container for Preprocessors::PreprocessedWord objects.

Attributes

original_word[RW]
preprocessed_words[RW]

Public Class Methods

new(original_word:, preprocessed_words:) click to toggle source

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.

# File lib/LittleWeasel/preprocessors/preprocessed_words.rb, line 17
def initialize(original_word:, preprocessed_words:)
  self.original_word = original_word
  self.preprocessed_words = preprocessed_words
end
preprocessed?(preprocessed_words:) click to toggle source

Returns true if the word was passed through any preprocessing. If this is the case, preprocessed_word may be different than original_word.

# File lib/LittleWeasel/preprocessors/preprocessed_words.rb, line 26
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:) click to toggle source
# File lib/LittleWeasel/preprocessors/preprocessed_words.rb, line 34
def preprocessed_word(preprocessed_words:)
  return unless preprocessed? preprocessed_words: preprocessed_words

  preprocessed_words.max_by(&:preprocessor_order).preprocessed_word
end

Public Instance Methods

preprocessed?() click to toggle source

Returns true if the word was preprocessed

# File lib/LittleWeasel/preprocessors/preprocessed_words.rb, line 46
def preprocessed?
  self.class.preprocessed? preprocessed_words: preprocessed_words
end
preprocessed_word() click to toggle source
# File lib/LittleWeasel/preprocessors/preprocessed_words.rb, line 41
def preprocessed_word
  self.class.preprocessed_word preprocessed_words: preprocessed_words
end