Class: Regexp::Expression::Conditional::Expression
Instance Attribute Summary collapse
#expressions
Instance Method Summary
collapse
#dig, #each_expression, #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, #full_length, #human_name, included, #is?, #nesting_level=, #offset, #one_of?, #optional?, #quantified?, #quantifier=, #quantifier_affix, #starts_at, #terminal?, #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 = {}) ⇒ 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 = {})
raise TooManyBranches.new if branches.length == 2
params = { 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
62
63
64
65
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 62
def initialize_copy(orig)
self.referenced_expression = orig.referenced_expression.dup
super
end
|
#parts ⇒ Object
58
59
60
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 58
def parts
[text.dup, condition, *intersperse(branches, '|'), ')']
end
|
#reference ⇒ Object
54
55
56
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 54
def reference
condition.reference
end
|