Module: RegexpPropertyValues::Extension

Defined in:
lib/regexp_property_values/extension.rb

Instance Method Summary collapse

Instance Method Details

#matched_charactersObject



24
25
26
# File 'lib/regexp_property_values/extension.rb', line 24

def matched_characters
  matched_codepoints.map { |cp| cp.chr('utf-8') }
end

#matched_codepointsObject

Ruby fallback - this stuff is slow as hell, and it wont get much faster



16
17
18
# File 'lib/regexp_property_values/extension.rb', line 16

def matched_codepoints
  matched_ranges.flat_map(&:to_a)
end

#matched_rangesObject



20
21
22
# File 'lib/regexp_property_values/extension.rb', line 20

def matched_ranges
  OnigRegexpPropertyHelper.matched_ranges(self)
end

#regexpObject



9
10
11
# File 'lib/regexp_property_values/extension.rb', line 9

def regexp
  @regexp ||= /\p{#{self}}/u
end

#supported_by_current_ruby?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'lib/regexp_property_values/extension.rb', line 3

def supported_by_current_ruby?
  !!regexp
rescue RegexpError, SyntaxError
  false
end