Module: RegexpPropertyValues::Value::RubyFallback
- Included in:
- RegexpPropertyValues::Value
- Defined in:
- lib/regexp_property_values/value/ruby_fallback.rb
Instance Method Summary collapse
Instance Method Details
#matched_characters ⇒ Object
4 5 6 |
# File 'lib/regexp_property_values/value/ruby_fallback.rb', line 4 def matched_characters matched_codepoints.map { |cp| cp.chr('utf-8') } end |
#matched_codepoints ⇒ Object
8 9 10 11 12 13 |
# File 'lib/regexp_property_values/value/ruby_fallback.rb', line 8 def matched_codepoints # turns out scanning one big string is the least slow way to do this @@test_str ||= (0..0xD7FF).map { |cp| cp.chr('utf-8') }.join << (0xE000..0x10FFFF).map { |cp| cp.chr('utf-8') }.join @@test_str.scan(regexp).flat_map(&:codepoints) end |
#matched_ranges ⇒ Object
15 16 17 18 |
# File 'lib/regexp_property_values/value/ruby_fallback.rb', line 15 def matched_ranges require 'range_compressor' RangeCompressor.compress(matched_codepoints) end |