Class: List::Matcher::Node

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

Direct Known Subclasses

Alternate, CharClass, Leaf, Sequence, SymbolPattern

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, symbols) ⇒ Node

Returns a new instance of Node.



454
455
456
457
458
# File 'lib/list_matcher.rb', line 454

def initialize(engine, symbols)
  @engine   = engine
  @symbols  = symbols
  @children = []
end

Instance Attribute Details

#engineObject

Returns the value of attribute engine.



452
453
454
# File 'lib/list_matcher.rb', line 452

def engine
  @engine
end

#optionalObject

Returns the value of attribute optional.



452
453
454
# File 'lib/list_matcher.rb', line 452

def optional
  @optional
end

#rootObject

Returns the value of attribute root.



452
453
454
# File 'lib/list_matcher.rb', line 452

def root
  @root
end

#symbolsObject

Returns the value of attribute symbols.



452
453
454
# File 'lib/list_matcher.rb', line 452

def symbols
  @symbols
end

Instance Method Details

#atomic?Boolean

Returns:

  • (Boolean)


504
505
506
# File 'lib/list_matcher.rb', line 504

def atomic?
  false
end

#boundObject



468
469
470
# File 'lib/list_matcher.rb', line 468

def bound
  engine.bound
end

#childrenObject



476
477
478
# File 'lib/list_matcher.rb', line 476

def children
  @children ||= []
end

#convertObject

Raises:

  • (NotImplementedError)


480
481
482
# File 'lib/list_matcher.rb', line 480

def convert
  raise NotImplementedError
end

#finalize(rx) ⇒ Object



492
493
494
495
496
497
498
# File 'lib/list_matcher.rb', line 492

def finalize(rx)
  if optional?
    rx = wrap rx unless atomic?
    rx += qmark
  end
  rx
end

#flattenObject



460
461
462
# File 'lib/list_matcher.rb', line 460

def flatten
  children.each{ |c| c.flatten }
end

#optional?Boolean

Returns:

  • (Boolean)


472
473
474
# File 'lib/list_matcher.rb', line 472

def optional?
  optional
end

#optionalize(bool) ⇒ Object



512
513
514
515
516
517
# File 'lib/list_matcher.rb', line 512

def optionalize(bool)
  if bool
    self.optional = bool
  end
  self
end

#pfxObject



484
485
486
# File 'lib/list_matcher.rb', line 484

def pfx
  engine.pfx
end

#qmarkObject



488
489
490
# File 'lib/list_matcher.rb', line 488

def qmark
  engine.qmark
end

#quote(s) ⇒ Object



508
509
510
# File 'lib/list_matcher.rb', line 508

def quote(s)
  engine.quote s
end

#root?Boolean

Returns:

  • (Boolean)


464
465
466
# File 'lib/list_matcher.rb', line 464

def root?
  root
end

#wrap(s) ⇒ Object



500
501
502
# File 'lib/list_matcher.rb', line 500

def wrap(s)
  engine.wrap s
end