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?, #pfx, #qmark, #quote, #root?, #wrap
Constructor Details
#initialize(engine, symbols, list) ⇒ Alternate
Returns a new instance of Alternate.
692 693 694 695 |
# File 'lib/list_matcher.rb', line 692 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
703 704 705 |
# File 'lib/list_matcher.rb', line 703 def atomic? !root? end |
#convert ⇒ Object
697 698 699 700 701 |
# File 'lib/list_matcher.rb', line 697 def convert rx = children.map(&:convert).join('|') rx = wrap(rx) unless root? finalize rx end |