Class: LittleWeasel::Filters::WordFilter

Inherits:
Object
  • Object
show all
Includes:
Modules::ClassNameToSymbol
Defined in:
lib/LittleWeasel/filters/word_filter.rb

Overview

This module provides methods/functionality for filtering dictionary words.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Modules::ClassNameToSymbol

included, #to_sym

Constructor Details

#initializeWordFilter

Returns a new instance of WordFilter.



14
15
16
# File 'lib/LittleWeasel/filters/word_filter.rb', line 14

def initialize
  filter_on!
end

Instance Attribute Details

#filter_onObject

Returns the value of attribute filter_on.



12
13
14
# File 'lib/LittleWeasel/filters/word_filter.rb', line 12

def filter_on
  @filter_on
end

Class Method Details

.filter_match?(_word) ⇒ Boolean

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.

Returns:

  • (Boolean)

Raises:



24
25
26
# File 'lib/LittleWeasel/filters/word_filter.rb', line 24

def filter_match?(_word)
  raise Errors::MustOverrideError
end

Instance Method Details

#filter_match?(word) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
# 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!Object



46
47
48
# File 'lib/LittleWeasel/filters/word_filter.rb', line 46

def filter_off!
  self.filter_on = false
end

#filter_off?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/LittleWeasel/filters/word_filter.rb', line 54

def filter_off?
  !filter_on?
end

#filter_on!Object



42
43
44
# File 'lib/LittleWeasel/filters/word_filter.rb', line 42

def filter_on!
  self.filter_on = true
end

#filter_on?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/LittleWeasel/filters/word_filter.rb', line 50

def filter_on?
  filter_on
end