Module: Gemmy::Patches::StringPatch::InstanceMethods::RangeAll
- Defined in:
- lib/gemmy/patches/string_patch.rb
Instance Method Summary collapse
-
#range_all(pattern, reuse = false) ⇒ Object
facets like #range patch but returns start/end indexes of all matches.
Instance Method Details
#range_all(pattern, reuse = false) ⇒ Object
facets like #range patch but returns start/end indexes of all matches
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/gemmy/patches/string_patch.rb', line 118 def range_all(pattern, reuse=false) r = []; i = 0 while i < self.length rng = range(pattern, i) if rng r << rng i += reuse ? 1 : rng.end + 1 else break end end r.uniq end |