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?, #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

Returns:

  • (Boolean)


703
704
705
# File 'lib/list_matcher.rb', line 703

def atomic?
  !root?
end

#convertObject



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