Class: Regexp::Expression::EscapeSequence::CodepointList

Inherits:
Base
  • Object
show all
Defined in:
lib/regexp_parser/expression/classes/escape_sequence.rb,
lib/regexp_parser/expression/methods/match_length.rb

Instance Attribute Summary

Attributes inherited from Base

#conditional_level, #level, #nesting_level, #options, #quantifier, #set_level, #text, #token, #ts, #type

Instance Method Summary collapse

Methods inherited from Base

#ascii_classes?, #attributes, #base_length, #case_insensitive?, #coded_offset, #default_classes?, #free_spacing?, #full_length, #greedy?, #initialize, #initialize_copy, #is?, #match, #match?, #multiline?, #offset, #one_of?, #possessive?, #quantified?, #quantifier_affix, #quantify, #quantity, #reluctant?, #repetitions, #strfregexp, #terminal?, #to_re, #to_s, #type?, #unicode_classes?, #unquantified_clone

Constructor Details

This class inherits a constructor from Regexp::Expression::Base

Instance Method Details

#charObject

Raises:

  • (NoMethodError)


41
42
43
# File 'lib/regexp_parser/expression/classes/escape_sequence.rb', line 41

def char
  raise NoMethodError, 'CodepointList responds only to #chars'
end

#charsObject



49
50
51
# File 'lib/regexp_parser/expression/classes/escape_sequence.rb', line 49

def chars
  codepoints.map { |cp| cp.chr('utf-8') }
end

#codepointObject

Raises:

  • (NoMethodError)


45
46
47
# File 'lib/regexp_parser/expression/classes/escape_sequence.rb', line 45

def codepoint
  raise NoMethodError, 'CodepointList responds only to #codepoints'
end

#codepointsObject



53
54
55
# File 'lib/regexp_parser/expression/classes/escape_sequence.rb', line 53

def codepoints
  text.scan(/\h+/).map(&:hex)
end

#match_lengthObject



160
161
162
# File 'lib/regexp_parser/expression/methods/match_length.rb', line 160

def match_length
  MatchLength.new(self, base: codepoints.count)
end