Class: List::Matcher::Alternate

Inherits:
Node
  • Object
show all
Defined in:
lib/list_matcher.rb

Instance Attribute Summary

Attributes inherited from Node

#engine, #optional, #root, #symbols

Instance Method Summary collapse

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.



759
760
761
762
# File 'lib/list_matcher.rb', line 759

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

Returns:

  • (Boolean)


770
771
772
# File 'lib/list_matcher.rb', line 770

def atomic?
  !root?
end

#convertObject



764
765
766
767
768
# File 'lib/list_matcher.rb', line 764

def convert
  rx = children.map(&:convert).join('|')
  rx = wrap(rx) unless root?
  finalize rx
end