Class: Filter::Phrase
Direct Known Subclasses
Constant Summary
Constants inherited from Filter
Instance Attribute Summary collapse
-
#mask ⇒ Object
readonly
Mask string.
-
#phrases ⇒ Object
readonly
Array of phrases.
Attributes inherited from Filter
Instance Method Summary collapse
-
#filter! ⇒ Object
Filter phrases.
-
#initialize(string, options = {}) ⇒ Phrase
constructor
Initialize with string and options.
Methods inherited from Filter
Profanity, Profanity!, #filter, inherited
Constructor Details
#initialize(string, options = {}) ⇒ Phrase
Initialize with string and options.
18 19 20 21 22 |
# File 'lib/filters/phrase.rb', line 18 def initialize string, = {} super @phrases = .fetch :phrases, [] @mask = .fetch :mask, nil end |
Instance Attribute Details
#mask ⇒ Object (readonly)
Mask string.
13 14 15 |
# File 'lib/filters/phrase.rb', line 13 def mask @mask end |
#phrases ⇒ Object (readonly)
Array of phrases.
8 9 10 |
# File 'lib/filters/phrase.rb', line 8 def phrases @phrases end |
Instance Method Details
#filter! ⇒ Object
Filter phrases.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/filters/phrase.rb', line 27 def filter! phrases.each do |phrase| if phrase.is_a? Array filter_with phrase.shift, phrase.shift else filter_with phrase, mask end end string.strip end |