Class: Uniword::FindReplace::Matcher
- Inherits:
-
Object
- Object
- Uniword::FindReplace::Matcher
- Defined in:
- lib/uniword/find_replace/matcher.rb
Overview
Abstract matcher: decides whether a string matches and what to replace it with.
Subclasses implement matches? (returns MatchData or nil) and
substitute (applies the replacement given MatchData). The
engine drives both via apply, which performs one substitution
pass over a single string and returns [new_string, count].
Direct Known Subclasses
Instance Method Summary collapse
-
#apply(text) ⇒ Array(String, Integer)
Apply the matcher to one string, replacing every non-overlapping match.
Instance Method Details
#apply(text) ⇒ Array(String, Integer)
Apply the matcher to one string, replacing every non-overlapping match. Returns the new string and the count of substitutions.
18 19 20 |
# File 'lib/uniword/find_replace/matcher.rb', line 18 def apply(text) raise NotImplementedError end |