Class: List::Matcher::Alternate
Instance Attribute Summary
Attributes inherited from Node
#engine, #optional, #root, #symbols
Instance Method Summary collapse
- #atomic? ⇒ Boolean
- #convert ⇒ Object
-
#initialize(engine, symbols, list) ⇒ Alternate
constructor
A new instance of Alternate.
Methods inherited from Node
#bound, #children, #finalize, #flatten, #optional?, #optionalize, #pfx, #qmark, #quote, #root?, #wrap
Constructor Details
#initialize(engine, symbols, list) ⇒ Alternate
Returns a new instance of Alternate.
745 746 747 748 |
# File 'lib/list_matcher.rb', line 745 def initialize(engine, symbols, list) super(engine, nil) @children = list.group_by{ |s| s[0] }.values.map{ |ar| engine.tree( ar, symbols ) } end |
Instance Method Details
#atomic? ⇒ Boolean
756 757 758 |
# File 'lib/list_matcher.rb', line 756 def atomic? !root? end |
#convert ⇒ Object
750 751 752 753 754 |
# File 'lib/list_matcher.rb', line 750 def convert rx = children.map(&:convert).join('|') rx = wrap(rx) unless root? finalize rx end |