class JsRegex::Converter::EscapeConverter
Template class implementation.
Constants
- ESCAPES_SHARED_BY_RUBY_AND_JS
Private Instance Methods
convert_codepoint_list()
click to toggle source
# File lib/js_regex/converter/escape_converter.rb, line 55 def convert_codepoint_list expression.chars.each_with_object(Node.new) do |char, node| node << LiteralConverter.convert_data(Regexp.escape(char)) end end
convert_data()
click to toggle source
# File lib/js_regex/converter/escape_converter.rb, line 38 def convert_data case subtype when :codepoint_list convert_codepoint_list when :control, :meta_sequence unicode_escape_codepoint when :literal LiteralConverter.convert_data(expression.char) when *ESCAPES_SHARED_BY_RUBY_AND_JS pass_through when :bell, :escape hex_escape_codepoint else warn_of_unsupported_feature end end
hex_escape_codepoint()
click to toggle source
# File lib/js_regex/converter/escape_converter.rb, line 65 def hex_escape_codepoint "\\x#{expression.codepoint.to_s(16).upcase.rjust(2, '0')}" end
unicode_escape_codepoint()
click to toggle source
# File lib/js_regex/converter/escape_converter.rb, line 61 def unicode_escape_codepoint "\\u#{expression.codepoint.to_s(16).upcase.rjust(4, '0')}" end