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, #terminal?, #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.
32
33
34
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 32
def referenced_expression
@referenced_expression
end
|
Instance Method Details
#<<(exp) ⇒ Object
34
35
36
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 34
def <<(exp)
expressions.last << exp
end
|
#add_sequence(active_opts = {}) ⇒ Object
Also known as:
branch
38
39
40
41
42
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 38
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
54
55
56
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 54
def branches
select { |subexp| subexp.is_a?(Sequence) }
end
|
#condition ⇒ Object
50
51
52
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 50
def condition
find { |subexp| subexp.is_a?(Condition) }
end
|
#condition=(exp) ⇒ Object
45
46
47
48
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 45
def condition=(exp)
expressions.delete(condition)
expressions.unshift(exp)
end
|
#initialize_copy(orig) ⇒ Object
70
71
72
73
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 70
def initialize_copy(orig)
self.referenced_expression = orig.referenced_expression.dup
super
end
|
#parts ⇒ Object
66
67
68
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 66
def parts
[text.dup, condition, *intersperse(branches, '|'), ')']
end
|
#reference ⇒ Object
58
59
60
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 58
def reference
condition.reference
end
|
#referential? ⇒ Boolean
62
63
64
|
# File 'lib/regexp_parser/expression/classes/conditional.rb', line 62
def referential?
true
end
|