Class: Regexp::Expression::Conditional::Condition

Inherits:
Base
  • Object
show all
Defined in:
lib/regexp_parser/expression/classes/conditional.rb

Instance Attribute Summary collapse

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, #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 Attribute Details

#referenced_expressionObject

Returns the value of attribute referenced_expression.



10
11
12
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 10

def referenced_expression
  @referenced_expression
end

Instance Method Details

#initialize_copy(orig) ⇒ Object



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

def initialize_copy(orig)
  self.referenced_expression = orig.referenced_expression.dup
  super
end

#referenceObject

Name or number of the referenced capturing group that determines state. Returns a String if reference is by name, Integer if by number.



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

def reference
  ref = text.tr("'<>()", "")
  ref =~ /\D/ ? ref : Integer(ref)
end