Class: List::Matcher::SpecialPattern

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

Instance Attribute Summary collapse

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, char, var, pat, atomic: (var.is_a?(Regexp) && pat.nil?), word_left: false, word_right: false) ⇒ SpecialPattern

Returns a new instance of SpecialPattern.



474
475
476
477
478
479
480
481
482
# File 'lib/list_matcher.rb', line 474

def initialize(engine, char, var, pat, atomic: (var.is_a?(Regexp) && pat.nil?), word_left: false, word_right: false)
  super(engine, nil)
  @char = char
  @var = var.is_a?(String) || var.is_a?(Symbol) ? Regexp.new(Regexp.quote(var.to_s)) : var
  @pat = pat || var.to_s
  @atomic = !!atomic
  @left = !!word_left
  @right = !!word_right
end

Instance Attribute Details

#charObject

Returns the value of attribute char.



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

def char
  @char
end

#leftObject

Returns the value of attribute left.



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

def left
  @left
end

#patObject

Returns the value of attribute pat.



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

def pat
  @pat
end

#rightObject

Returns the value of attribute right.



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

def right
  @right
end

#varObject

Returns the value of attribute var.



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

def var
  @var
end

Instance Method Details

#atomic?Boolean

Returns:

  • (Boolean)


492
493
494
# File 'lib/list_matcher.rb', line 492

def atomic?
  @atomic
end

#convertObject



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

def convert
  rx = @pat
  finalize rx
end

#left?Boolean

Returns:

  • (Boolean)


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

def left?
  @left
end

#right?Boolean

Returns:

  • (Boolean)


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

def right?
  @right
end

#to_sObject



496
497
498
# File 'lib/list_matcher.rb', line 496

def to_s
  self.char
end