Class: List::Matcher::Node

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

Direct Known Subclasses

Alternate, CharClass, Leaf, Sequence, SpecialPattern

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, symbols) ⇒ Node

Returns a new instance of Node.



412
413
414
415
416
# File 'lib/list_matcher.rb', line 412

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

Instance Attribute Details

#engineObject

Returns the value of attribute engine.



410
411
412
# File 'lib/list_matcher.rb', line 410

def engine
  @engine
end

#optionalObject

Returns the value of attribute optional.



410
411
412
# File 'lib/list_matcher.rb', line 410

def optional
  @optional
end

#rootObject

Returns the value of attribute root.



410
411
412
# File 'lib/list_matcher.rb', line 410

def root
  @root
end

#symbolsObject

Returns the value of attribute symbols.



410
411
412
# File 'lib/list_matcher.rb', line 410

def symbols
  @symbols
end

Instance Method Details

#atomic?Boolean

Returns:

  • (Boolean)


462
463
464
# File 'lib/list_matcher.rb', line 462

def atomic?
  false
end

#boundObject



426
427
428
# File 'lib/list_matcher.rb', line 426

def bound
  engine.bound
end

#childrenObject



434
435
436
# File 'lib/list_matcher.rb', line 434

def children
  @children ||= []
end

#convertObject

Raises:

  • (NotImplementedError)


438
439
440
# File 'lib/list_matcher.rb', line 438

def convert
  raise NotImplementedError
end

#finalize(rx) ⇒ Object



450
451
452
453
454
455
456
# File 'lib/list_matcher.rb', line 450

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

#flattenObject



418
419
420
# File 'lib/list_matcher.rb', line 418

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

#optional?Boolean

Returns:

  • (Boolean)


430
431
432
# File 'lib/list_matcher.rb', line 430

def optional?
  optional
end

#pfxObject



442
443
444
# File 'lib/list_matcher.rb', line 442

def pfx
  engine.pfx
end

#qmarkObject



446
447
448
# File 'lib/list_matcher.rb', line 446

def qmark
  engine.qmark
end

#quote(s) ⇒ Object



466
467
468
# File 'lib/list_matcher.rb', line 466

def quote(s)
  engine.quote s
end

#root?Boolean

Returns:

  • (Boolean)


422
423
424
# File 'lib/list_matcher.rb', line 422

def root?
  root
end

#wrap(s) ⇒ Object



458
459
460
# File 'lib/list_matcher.rb', line 458

def wrap(s)
  engine.wrap s
end