Class: NgWord::ExcludeWordRule
- Inherits:
-
Object
- Object
- NgWord::ExcludeWordRule
- Defined in:
- lib/ng_word/exclude_word_rule.rb
Instance Method Summary collapse
-
#initialize(downcased_ng_word, exclude_word) ⇒ ExcludeWordRule
constructor
A new instance of ExcludeWordRule.
- #match?(downcased_text, matched_index) ⇒ Boolean
Constructor Details
#initialize(downcased_ng_word, exclude_word) ⇒ ExcludeWordRule
Returns a new instance of ExcludeWordRule.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ng_word/exclude_word_rule.rb', line 3 def initialize(downcased_ng_word, exclude_word) @downcased_ng_word = downcased_ng_word @exclude_word = exclude_word @downcased_exclude_word = exclude_word.downcase @index = @downcased_exclude_word.index(@downcased_ng_word) @length = @downcased_exclude_word.length freeze end |
Instance Method Details
#match?(downcased_text, matched_index) ⇒ Boolean
14 15 16 |
# File 'lib/ng_word/exclude_word_rule.rb', line 14 def match?(downcased_text, matched_index) downcased_text.slice(matched_index - index, length) == downcased_exclude_word end |