Class: FuzzyMatch::Rule::Normalizer
- Inherits:
-
FuzzyMatch::Rule
- Object
- FuzzyMatch::Rule
- FuzzyMatch::Rule::Normalizer
- Defined in:
- lib/fuzzy_match/rule/normalizer.rb
Overview
A normalizer just strips a string down to its core
Instance Attribute Summary
Attributes inherited from FuzzyMatch::Rule
Instance Method Summary collapse
-
#apply(str) ⇒ Object
The result of applying a normalizer is just all the captures put together.
-
#apply?(str) ⇒ Boolean
A normalizer applies when its regexp matches and captures a new (shorter) string.
Methods inherited from FuzzyMatch::Rule
Constructor Details
This class inherits a constructor from FuzzyMatch::Rule
Instance Method Details
#apply(str) ⇒ Object
The result of applying a normalizer is just all the captures put together.
11 12 13 14 15 16 17 |
# File 'lib/fuzzy_match/rule/normalizer.rb', line 11 def apply(str) if match_data = regexp.match(str) match_data.captures.join else str end end |
#apply?(str) ⇒ Boolean
A normalizer applies when its regexp matches and captures a new (shorter) string
6 7 8 |
# File 'lib/fuzzy_match/rule/normalizer.rb', line 6 def apply?(str) !!(regexp.match(str)) end |