Class: JsRegex::Converter::TypeConverter

Inherits:
Base
  • Object
show all
Defined in:
lib/js_regex/converter/type_converter.rb

Overview

Template class implementation.

Constant Summary collapse

HEX_EXPANSION =
'[0-9A-Fa-f]'
NONHEX_EXPANSION =
'[^0-9A-Fa-f]'
I_MODE_HEX_EXPANSION =
'[0-9A-F]'
I_MODE_NONHEX_EXPANSION =
'[^0-9A-F]'
ES2018_HEX_EXPANSION =
'\p{AHex}'
ES2018_NONHEX_EXPANSION =
'\P{AHex}'
ES2018_XGRAPHEME_EXPANSION =
'[\P{M}\P{Lm}](?:(?:[\u035C\u0361]\P{M}\p{M}*)|\u200d|\p{M}|\p{Lm}|\p{Emoji_Modifier})*'
LINEBREAK_EXPANSION =
'(?:\r\n|[\n\v\f\r\u0085\u2028\u2029])'

Class Method Summary collapse

Methods inherited from Base

#convert

Class Method Details

.directly_compatible?(expression, _context = nil) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/js_regex/converter/type_converter.rb', line 18

def self.directly_compatible?(expression, _context = nil)
  case expression.token
  when :space, :nonspace
    !expression.ascii_classes?
  when :digit, :nondigit, :word, :nonword
    !expression.unicode_classes?
  end
end