Sha256: 5c7c55500e2ade70417ebb83609f6e005abc38ff32d5f3e9b6c9067655bdb8d7

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 Bytes

Contents

class FuzzyMatch
  class Rule
    # Identities take effect when needle and haystack both match a regexp
    # Then the captured part of the regexp has to match exactly
    class Identity < Rule
      # Two strings are "identical" if they both match this identity and the captures are equal.
      #
      # Only returns true/false if both strings match the regexp.
      # Otherwise returns nil.
      def identical?(record1, record2)
        if str1_match_data = regexp.match(record1.whole) and str2_match_data = regexp.match(record2.whole)
          str1_match_data.captures.join.downcase == str2_match_data.captures.join.downcase
        else
          nil
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fuzzy_match-2.0.1 lib/fuzzy_match/rule/identity.rb
fuzzy_match-2.0.0 lib/fuzzy_match/rule/identity.rb