class JsRegex::Converter::PropertyConverter
Template class implementation.
Uses the ‘character_set` and `regexp_property_values` gems to get the codepoints matched by the property and build a set string from them.
Public Class Methods
Source
# File lib/js_regex/converter/property_converter.rb, line 14 def self.map @map ||= File.read("#{__dir__}/property_map.csv").scan(/(.+),(.+)/).to_h end
A map of normalized Ruby property names to names supported by ES2018+.
Private Instance Methods
Source
# File lib/js_regex/converter/property_converter.rb, line 30 def build_character_set content = CharacterSet.of_expression(expression) if expression.case_insensitive? && !context.case_insensitive_root content = content.case_insensitive elsif !expression.case_insensitive? && context.case_insensitive_root warn_of_unsupported_feature('nested case-sensitive property') end content.to_s_with_surrogate_ranges end
Source
# File lib/js_regex/converter/property_converter.rb, line 20 def convert_data if context.es_2018_or_higher? && (prop_name_in_js = self.class.map[subtype.to_s.tr('_', '')]) context.enable_u_option "\\#{expression.negative? ? 'P' : 'p'}{#{prop_name_in_js}}" else build_character_set end end