Class: LittleWeasel::Filters::WordFilter
- Inherits:
-
Object
- Object
- LittleWeasel::Filters::WordFilter
- Includes:
- Modules::ClassNameToSymbol
- Defined in:
- lib/LittleWeasel/filters/word_filter.rb
Overview
This module provides methods/functionality for filtering dictionary words.
Direct Known Subclasses
EnUs::CurrencyFilter, EnUs::NumericFilter, EnUs::SingleCharacterWordFilter
Instance Attribute Summary collapse
-
#filter_on ⇒ Object
Returns the value of attribute filter_on.
Class Method Summary collapse
-
.filter_match?(_word) ⇒ Boolean
Should return true if this word matches the filter criteria; false, otherwise.
Instance Method Summary collapse
- #filter_match?(word) ⇒ Boolean
- #filter_off! ⇒ Object
- #filter_off? ⇒ Boolean
- #filter_on! ⇒ Object
- #filter_on? ⇒ Boolean
-
#initialize ⇒ WordFilter
constructor
A new instance of WordFilter.
Methods included from Modules::ClassNameToSymbol
Constructor Details
#initialize ⇒ WordFilter
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_on ⇒ Object
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.
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
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
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
50 51 52 |
# File 'lib/LittleWeasel/filters/word_filter.rb', line 50 def filter_on? filter_on end |