class LittleWeasel::BlockResults

This class represents the results of gathering information about a word block (group of words).

Attributes

original_word_block[RW]

:reek: Attribute - Ignored, it doesn't make sense to create a formal setter method.

word_results[RW]

:reek: Attribute - Ignored, it doesn't make sense to create a formal setter method.

Public Class Methods

new(original_word_block:) click to toggle source
# File lib/LittleWeasel/block_results.rb, line 13
def initialize(original_word_block:)
  self.original_word_block = original_word_block
  self.word_results = []
end

Public Instance Methods

<<(word_result) click to toggle source
# File lib/LittleWeasel/block_results.rb, line 18
def <<(word_result)
  unless word_result.is_a? WordResults
    raise ArgumentError, "Argument word_result is not a WordResults object: #{word_result.class}"
  end

  word_results << word_result
end
filters_match?() click to toggle source

Returns true if all WordResults object words have filter matches (filters_match?); false otherwise.

# File lib/LittleWeasel/block_results.rb, line 44
def filters_match?
  return false unless word_results.present?

  word_results.all?(&:filter_match?)
end
preprocessed_words?() click to toggle source

Returns true if all WordResults object words have been preprocessed (preprocessed_words?); false otherwise.

# File lib/LittleWeasel/block_results.rb, line 52
def preprocessed_words?
  return false unless word_results.present?

  word_results.all?(&:preprocessed_word?)
end
preprocessed_words_or_original_words() click to toggle source

Calls preprocessed_word_or_original_word on all WordResults objects. An Array of the results is returned.

# File lib/LittleWeasel/block_results.rb, line 63
def preprocessed_words_or_original_words
  return [] unless word_results.present?

  word_results.map(&:preprocessed_word_or_original_word)
end
success?() click to toggle source

Calls success? on all WordResults objects. Returns true if all WordResults return true; false is returned otherwise.

# File lib/LittleWeasel/block_results.rb, line 28
def success?
  return false unless word_results.present?

  word_results.all?(&:success?)
end
words_cached?() click to toggle source

Returns true if all WordResults object words have been cached (words_cached?); false otherwise.

# File lib/LittleWeasel/block_results.rb, line 71
def words_cached?
  return false unless word_results.present?

  word_results.all?(&:word_cached?)
end
words_valid?() click to toggle source

Returns true if all WordResults object words are valid (word_valid?); false otherwise.

# File lib/LittleWeasel/block_results.rb, line 36
def words_valid?
  return false unless word_results.present?

  word_results.all?(&:word_valid?)
end