Sha256: 92c22a77826615aa300c7e9418b726bec7213714c70e0469a5f32d9723a65dc2
Contents?: true
Size: 726 Bytes
Versions: 4
Compression:
Stored size: 726 Bytes
Contents
class FuzzyMatch # Identities take effect when needle and haystack both match a regexp # Then the captured part of the regexp has to match exactly class Identity attr_reader :regexp def initialize(regexp_or_str) @regexp = regexp_or_str.to_regexp end # 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
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fuzzy_match-1.3.1 | lib/fuzzy_match/identity.rb |
fuzzy_match-1.3.0 | lib/fuzzy_match/identity.rb |
fuzzy_match-1.2.2 | lib/fuzzy_match/identity.rb |
fuzzy_match-1.2.1 | lib/fuzzy_match/identity.rb |