Class: Regexp::Expression::Backreference::Base

Inherits:
Regexp::Expression::Base show all
Defined in:
lib/regexp_parser/expression/classes/backreference.rb

Direct Known Subclasses

Name, Number

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Regexp::Expression::Base

#ascii_classes?, #case_insensitive?, #default_classes?, #free_spacing?, #greedy?, #initialize, #match, #match?, #multiline?, #possessive?, #quantify, #quantity, #reluctant?, #repetitions, #strfregexp, #to_h, #to_re, #unicode_classes?, #unquantified_clone

Methods included from Shared

#==, #base_length, #coded_offset, #ends_at, #full_length, #human_name, included, #inspect, #is?, #negated?, #negative?, #nesting_level=, #offset, #one_of?, #optional?, #parts, #pre_quantifier_decoration, #pretty_print, #pretty_print_instance_variables, #quantified?, #quantifier=, #quantifier_affix, #starts_at, #to_s, #token_class, #type?

Constructor Details

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

Instance Attribute Details

#referenced_expressionObject

Returns the value of attribute referenced_expression.



4
5
6
# File 'lib/regexp_parser/expression/classes/backreference.rb', line 4

def referenced_expression
  @referenced_expression
end

Instance Method Details

#initialize_copy(orig) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/regexp_parser/expression/classes/backreference.rb', line 6

def initialize_copy(orig)
  exp_id = [self.class, self.starts_at]

  # prevent infinite recursion for recursive subexp calls
  copied = @@copied ||= {}
  self.referenced_expression =
    if copied[exp_id]
      orig.referenced_expression
    else
      copied[exp_id] = true
      orig.referenced_expression.dup
    end
  copied.clear

  super
end