Module: Regexp::Expression::ReferencedExpressions

Included in:
Base
Defined in:
lib/regexp_parser/expression/methods/referenced_expressions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#referenced_expressionsObject

Returns the value of attribute referenced_expressions.



3
4
5
# File 'lib/regexp_parser/expression/methods/referenced_expressions.rb', line 3

def referenced_expressions
  @referenced_expressions
end

Instance Method Details

#initialize_copy(orig) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/regexp_parser/expression/methods/referenced_expressions.rb', line 9

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

  # prevent infinite recursion for recursive subexp calls
  copied = self.class.instance_eval { @copied_ref_exps ||= {} }
  self.referenced_expressions =
    if copied[exp_id]
      orig.referenced_expressions
    else
      copied[exp_id] = true
      orig.referenced_expressions && orig.referenced_expressions.map(&:dup)
    end
  copied.clear

  super
end

#referenced_expressionObject



5
6
7
# File 'lib/regexp_parser/expression/methods/referenced_expressions.rb', line 5

def referenced_expression
  referenced_expressions && referenced_expressions.first
end