Class: List::Matcher::SymbolPattern
Instance Attribute Summary collapse
-
#char ⇒ Object
Returns the value of attribute char.
-
#left ⇒ Object
Returns the value of attribute left.
-
#pat ⇒ Object
Returns the value of attribute pat.
-
#right ⇒ Object
Returns the value of attribute right.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#var ⇒ Object
Returns the value of attribute var.
Attributes inherited from Node
#engine, #optional, #root, #symbols
Instance Method Summary collapse
- #atomic? ⇒ Boolean
- #convert ⇒ Object
- #dup ⇒ Object
-
#initialize(engine, char, var, pat, atomic: (var.is_a?(Regexp) && pat.nil?), left: nil, right: nil) ⇒ SymbolPattern
constructor
A new instance of SymbolPattern.
- #optionalize(bool) ⇒ Object
- #to_s ⇒ Object
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?), left: nil, right: nil) ⇒ SymbolPattern
Returns a new instance of SymbolPattern.
523 524 525 526 527 528 529 530 531 532 |
# File 'lib/list_matcher.rb', line 523 def initialize(engine, char, var, pat, atomic: (var.is_a?(Regexp) && pat.nil?), left: nil, right: nil) super(engine, nil) @char = char @symbol = var.to_s @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 = left @right = right end |
Instance Attribute Details
#char ⇒ Object
Returns the value of attribute char.
522 523 524 |
# File 'lib/list_matcher.rb', line 522 def char @char end |
#left ⇒ Object
Returns the value of attribute left.
522 523 524 |
# File 'lib/list_matcher.rb', line 522 def left @left end |
#pat ⇒ Object
Returns the value of attribute pat.
522 523 524 |
# File 'lib/list_matcher.rb', line 522 def pat @pat end |
#right ⇒ Object
Returns the value of attribute right.
522 523 524 |
# File 'lib/list_matcher.rb', line 522 def right @right end |
#symbol ⇒ Object
Returns the value of attribute symbol.
522 523 524 |
# File 'lib/list_matcher.rb', line 522 def symbol @symbol end |
#var ⇒ Object
Returns the value of attribute var.
522 523 524 |
# File 'lib/list_matcher.rb', line 522 def var @var end |
Instance Method Details
#atomic? ⇒ Boolean
538 539 540 |
# File 'lib/list_matcher.rb', line 538 def atomic? @atomic end |
#convert ⇒ Object
546 547 548 549 |
# File 'lib/list_matcher.rb', line 546 def convert rx = @pat finalize rx end |
#dup ⇒ Object
534 535 536 |
# File 'lib/list_matcher.rb', line 534 def dup self.class.new engine, char, var, pat, atomic: atomic?, left: left, right: right end |
#optionalize(bool) ⇒ Object
551 552 553 554 555 556 557 558 |
# File 'lib/list_matcher.rb', line 551 def optionalize(bool) n = self if bool n = n.dup n.optional = bool end n end |
#to_s ⇒ Object
542 543 544 |
# File 'lib/list_matcher.rb', line 542 def to_s self.char end |