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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from 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, #full_length, included, #is?, #nesting_level=, #offset, #one_of?, #parts, #quantified?, #quantifier_affix, #starts_at, #terminal?, #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.



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