Sha256: 9f2bbefbb83dc73738d2cd35b679783f1d8b51d989090bb25ef6c4952394900c

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

module NgWord
  class ExcludeWordRule
    def initialize(downcased_ng_word, exclude_word)
      @downcased_ng_word = downcased_ng_word
      @exclude_word = exclude_word
    end

    def match?(downcased_text, matched_index)
      downcased_text.slice(matched_index - index, length) == @downcased_exclude_word
    end

    private

    def downcased_exclude_word
      @downcased_exclude_word ||= @exclude_word.downcase
    end

    def index
      @index ||= downcased_exclude_word.index(@downcased_ng_word)
    end

    def length
      @length ||= downcased_exclude_word.length
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ng_word-0.1.0 lib/ng_word/exclude_word_rule.rb