| 1 | # frozen_string_literal: true |
| 2 | |
| 3 | # re2 (https://github.com/mudge/re2) |
| 4 | # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to |
| 5 | # backtracking regular expression engines like those used in PCRE, Perl, and |
| 6 | # Python". |
| 7 | # |
| 8 | # Copyright (c) 2010, Paul Mucur (https://mudge.name) |
| 9 | # Released under the BSD Licence, please see LICENSE.txt |
| 10 | |
| 11 | |
| 12 | module RE2 |
| 13 | class Scanner |
| 14 | include Enumerable |
| 15 | |
| 16 | def each |
| 17 | if block_given? |
| 18 | while matches = scan |
| 19 | yield matches |
| 20 | end |
| 21 | else |
| 22 | to_enum(:each) |
| 23 | end |
| 24 | end |
| 25 | end |
| 26 | end |