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
#level, #options, #quantifier, #text, #token, #ts, #type
Instance Method Summary
collapse
#[], #clone, #each, #each_with_index, #first, #initialize, #insert, #last, #length
Methods inherited from Base
#case_insensitive?, #clone, #coded_offset, #free_spacing?, #full_length, #greedy?, #initialize, #multiline?, #offset, #possessive?, #quantified?, #quantity, #reluctant?, #terminal?, #to_re
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 : Sequence.new)
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
|