class LittleWeasel::Filters::WordFilter

This module provides methods/functionality for filtering dictionary words.

Attributes

filter_on[R]

Public Class Methods

filter_match?(_word) click to toggle source

Should return true if this word matches the filter criteria; false, otherwise. This class method is unlike the instance method in that it does not consider whether or not this filter is “on” or “off”; it simply returns true or false based on whether or not the word matches the filter.

# File lib/LittleWeasel/filters/word_filter.rb, line 24
def filter_match?(_word)
  raise Errors::MustOverrideError
end
new() click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 14
def initialize
  filter_on!
end

Public Instance Methods

filter_match?(word) click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 36
def filter_match?(word)
  return false if filter_off?

  self.class.filter_match? word
end
filter_off!() click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 46
def filter_off!
  self.filter_on = false
end
filter_off?() click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 54
def filter_off?
  !filter_on?
end
filter_on!() click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 42
def filter_on!
  self.filter_on = true
end
filter_on=(value) click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 29
def filter_on=(value)
  raise ArgumentError, "Argument value is not true or false: #{value.class}" \
    unless [true, false].include? value

  @filter_on = value
end
filter_on?() click to toggle source
# File lib/LittleWeasel/filters/word_filter.rb, line 50
def filter_on?
  filter_on
end