Class: Regexp::Expression::Alternation
Overview
This is not a subexpression really, but considering it one simplifies the API when it comes to handling the alternatives.
Instance Attribute Summary
#expressions
Attributes inherited from Base
#conditional_level, #level, #options, #quantifier, #set_level, #text, #token, #ts, #type
Instance Method Summary
collapse
#[], #all?, #clone, #each, #each_expression, #each_with_index, #empty?, #first, #initialize, #insert, #last, #length, #map, #strfregexp_tree, #te, #to_h, #traverse, #ts
Methods inherited from Base
#ascii_classes?, #case_insensitive?, #clone, #coded_offset, #default_classes?, #free_spacing?, #full_length, #greedy?, #initialize, #is?, #match, #matches?, #multiline?, #offset, #one_of?, #possessive?, #quantified?, #quantity, #reluctant?, #strfregexp, #terminal?, #to_h, #to_re, #type?, #unicode_classes?
Instance Method Details
#<<(exp) ⇒ Object
10
11
12
|
# File 'lib/regexp_parser/expression/classes/alternation.rb', line 10
def <<(exp)
@expressions.last << exp
end
|
#alternative(exp = nil) ⇒ Object
14
15
16
|
# File 'lib/regexp_parser/expression/classes/alternation.rb', line 14
def alternative(exp = nil)
@expressions << (exp ? exp : Alternative.new(level, set_level, conditional_level))
end
|
#alternatives ⇒ Object
18
19
20
|
# File 'lib/regexp_parser/expression/classes/alternation.rb', line 18
def alternatives
@expressions
end
|
#quantify(token, text, min = nil, max = nil, mode = :greedy) ⇒ Object
22
23
24
|
# File 'lib/regexp_parser/expression/classes/alternation.rb', line 22
def quantify(token, text, min = nil, max = nil, mode = :greedy)
alternatives.last.last.quantify(token, text, min, max, mode)
end
|
#starts_at ⇒ Object
6
7
8
|
# File 'lib/regexp_parser/expression/classes/alternation.rb', line 6
def starts_at
@expressions.first.starts_at
end
|
#to_s(format = :full) ⇒ Object
26
27
28
|
# File 'lib/regexp_parser/expression/classes/alternation.rb', line 26
def to_s(format = :full)
alternatives.map{|e| e.to_s(format)}.join('|')
end
|