lib/LittleWeasel/preprocessors/preprocessed_words.rb in LittleWeasel-4.0.0 vs lib/LittleWeasel/preprocessors/preprocessed_words.rb in LittleWeasel-5.0.0
- old
+ new
@@ -3,12 +3,11 @@
module LittleWeasel
module Preprocessors
# This class provides a container for Preprocessors::PreprocessedWord
# objects.
class PreprocessedWords
- attr_reader :original_word
- attr_accessor :preprocessed_words
+ attr_reader :original_word, :preprocessed_words
# 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
@@ -34,9 +33,14 @@
def preprocessed_word(preprocessed_words:)
return unless preprocessed? preprocessed_words: preprocessed_words
preprocessed_words.max_by(&:preprocessor_order).preprocessed_word
end
+ end
+
+ def preprocessed_words=(value)
+ value ||= []
+ @preprocessed_words = value
end
def preprocessed_word
self.class.preprocessed_word preprocessed_words: preprocessed_words
end