Class: Regexp::Expression::Root

Inherits:
Subexpression show all
Defined in:
lib/regexp_parser/expression/classes/root.rb

Instance Attribute Summary

Attributes inherited from Subexpression

#expressions

Attributes inherited from Base

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Subexpression

#<<, #dig, #each_expression, #flat_map, #initialize_clone, #inner_match_length, #match_length, #strfregexp_tree, #te, #to_h, #to_s, #traverse

Methods inherited from Base

#ascii_classes?, #attributes, #case_insensitive?, #coded_offset, #default_classes?, #free_spacing?, #full_length, #greedy?, #initialize_clone, #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

#initialize(*args) ⇒ Root

TODO: this override is here for backwards compatibility, remove in 2.0.0



5
6
7
8
9
10
11
12
# File 'lib/regexp_parser/expression/classes/root.rb', line 5

def initialize(*args)
  unless args.first.is_a?(Regexp::Token)
    warn('WARNING: Root.new without a Token argument is deprecated and '\
         'will be removed in 2.0.0. Use Root.build for the old behavior.')
    return super(self.class.build_token, *args)
  end
  super
end

Class Method Details

.build(options = {}) ⇒ Object



15
16
17
# File 'lib/regexp_parser/expression/classes/root.rb', line 15

def build(options = {})
  new(build_token, options)
end

.build_tokenObject



19
20
21
# File 'lib/regexp_parser/expression/classes/root.rb', line 19

def build_token
  Regexp::Token.new(:expression, :root, '', 0)
end