Class: FuzzyMatch::Rule::Identity
- Inherits:
-
FuzzyMatch::Rule
- Object
- FuzzyMatch::Rule
- FuzzyMatch::Rule::Identity
- Defined in:
- lib/fuzzy_match/rule/identity.rb
Overview
Identities take effect when needle and haystack both match a regexp Then the captured part of the regexp has to match exactly
Instance Attribute Summary
Attributes inherited from FuzzyMatch::Rule
Instance Method Summary collapse
-
#identical?(str1, str2) ⇒ Boolean
Two strings are “identical” if they both match this identity and the captures are equal.
Methods inherited from FuzzyMatch::Rule
Constructor Details
This class inherits a constructor from FuzzyMatch::Rule
Instance Method Details
#identical?(str1, str2) ⇒ Boolean
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.
10 11 12 13 14 15 16 |
# File 'lib/fuzzy_match/rule/identity.rb', line 10 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 |