class ProfanityFilterEngine::Composite
Attributes
strategies[R]
Public Class Methods
new()
click to toggle source
# File lib/profanity-filter/engines/composite.rb, line 10 def initialize @strategies = [] end
Public Instance Methods
add_strategies(*new_strategies)
click to toggle source
# File lib/profanity-filter/engines/composite.rb, line 18 def add_strategies(*new_strategies) strategies.concat(new_strategies) end
add_strategy(strategy)
click to toggle source
# File lib/profanity-filter/engines/composite.rb, line 14 def add_strategy(strategy) strategies << strategy end
delete_strategy(strategy)
click to toggle source
# File lib/profanity-filter/engines/composite.rb, line 22 def delete_strategy(strategy) strategies.delete(strategy) end
profane?(text)
click to toggle source
# File lib/profanity-filter/engines/composite.rb, line 26 def profane?(text) strategies.any? { |strategy| strategy.profane?(text) } end
profane_words(text)
click to toggle source
# File lib/profanity-filter/engines/composite.rb, line 30 def profane_words(text) total_words = strategies.reduce([]) do |words, strategy| words.concat(strategy.profane_words(text).map { |w| w.gsub(/[ _\-\.]/, '') }) end total_words.uniq end