Sha256: 9b68dbf147b20d59dfd311ce4494ff51e23a3b6ab67fac0aba3c27de0fa2d84f

Contents?: true

Size: 666 Bytes

Versions: 5

Compression:

Stored size: 666 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?(str1, str2)
        if str1_match_data = regexp.match(str1) and match_data = regexp.match(str2)
          str1_match_data.captures.join.downcase == match_data.captures.join.downcase
        else
          nil
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fuzzy_match-1.5.0 lib/fuzzy_match/rule/identity.rb
fuzzy_match-1.4.1 lib/fuzzy_match/rule/identity.rb
fuzzy_match-1.4.0 lib/fuzzy_match/rule/identity.rb
fuzzy_match-1.3.3 lib/fuzzy_match/rule/identity.rb
fuzzy_match-1.3.2 lib/fuzzy_match/rule/identity.rb