Class: ProfanityFilterEngine::ExactMatchStrategy

Inherits:
RegexpStrategy show all
Defined in:
lib/profanity-filter/engines/exact_match_strategy.rb

Constant Summary collapse

DELIMITER =
'(?:\b|^|$|_)'
DEFAULT_IGNORE_CASE =
false

Constants inherited from RegexpStrategy

RegexpStrategy::DEFAULT_DELIMITER

Instance Attribute Summary collapse

Attributes inherited from RegexpStrategy

#dictionary, #profanity_regexp

Instance Method Summary collapse

Methods inherited from RegexpStrategy

#profane?, #profane_words

Methods inherited from Component

#profane?, #profane_words, #profanity_count

Constructor Details

#initialize(dictionary:, ignore_case: DEFAULT_IGNORE_CASE) ⇒ ExactMatchStrategy

Returns a new instance of ExactMatchStrategy.



13
14
15
16
17
18
# File 'lib/profanity-filter/engines/exact_match_strategy.rb', line 13

def initialize(dictionary:, ignore_case: DEFAULT_IGNORE_CASE)
  @dictionary = dictionary
  @delimiter = DELIMITER
  @ignore_case = ignore_case
  @profanity_regexp = build_profanity_regexp
end

Instance Attribute Details

#delimiterObject (readonly)

Returns the value of attribute delimiter.



10
11
12
# File 'lib/profanity-filter/engines/exact_match_strategy.rb', line 10

def delimiter
  @delimiter
end

#ignore_caseObject (readonly)

Returns the value of attribute ignore_case.



11
12
13
# File 'lib/profanity-filter/engines/exact_match_strategy.rb', line 11

def ignore_case
  @ignore_case
end