Class: Regexp::Expression::Conditional::Expression
Instance Attribute Summary collapse
#expressions
Instance Method Summary
collapse
#dig, #each_expression, #extract_quantifier_target, #flat_map, #initialize, #inner_match_length, #match_length, #strfregexp_tree, #te, #to_h, #traverse
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, #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?
Instance Attribute Details
#referenced_expression ⇒ Object
Returns the value of attribute referenced_expression.
28
29
30
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 28
def referenced_expression
@referenced_expression
end
|
Instance Method Details
#<<(exp) ⇒ Object
30
31
32
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 30
def <<(exp)
expressions.last << exp
end
|
#add_sequence(active_opts = {}, params = { ts: 0 }) ⇒ Object
Also known as:
branch
34
35
36
37
38
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 34
def add_sequence(active_opts = {}, params = { ts: 0 })
raise TooManyBranches.new if branches.length == 2
params = params.merge({ conditional_level: conditional_level + 1 })
Branch.add_to(self, params, active_opts)
end
|
#branches ⇒ Object
50
51
52
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 50
def branches
select { |subexp| subexp.is_a?(Sequence) }
end
|
#condition ⇒ Object
46
47
48
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 46
def condition
find { |subexp| subexp.is_a?(Condition) }
end
|
#condition=(exp) ⇒ Object
41
42
43
44
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 41
def condition=(exp)
expressions.delete(condition)
expressions.unshift(exp)
end
|
#initialize_copy(orig) ⇒ Object
58
59
60
61
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 58
def initialize_copy(orig)
self.referenced_expression = orig.referenced_expression.dup
super
end
|
#reference ⇒ Object
54
55
56
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 54
def reference
condition.reference
end
|