Class: Journey::Path::Pattern::RegexpOffsets
- Inherits:
-
Visitors::Visitor
- Object
- Visitors::Visitor
- Journey::Path::Pattern::RegexpOffsets
- Defined in:
- lib/journey/path/pattern.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#offsets ⇒ Object
readonly
Returns the value of attribute offsets.
Instance Method Summary collapse
-
#initialize(matchers) ⇒ RegexpOffsets
constructor
A new instance of RegexpOffsets.
- #visit(node) ⇒ Object
- #visit_SYMBOL(node) ⇒ Object
Methods inherited from Visitors::Visitor
Constructor Details
#initialize(matchers) ⇒ RegexpOffsets
Returns a new instance of RegexpOffsets.
62 63 64 65 |
# File 'lib/journey/path/pattern.rb', line 62 def initialize matchers @matchers = matchers @capture_count = [0] end |
Instance Attribute Details
#offsets ⇒ Object (readonly)
Returns the value of attribute offsets.
60 61 62 |
# File 'lib/journey/path/pattern.rb', line 60 def offsets @offsets end |
Instance Method Details
#visit(node) ⇒ Object
67 68 69 70 |
# File 'lib/journey/path/pattern.rb', line 67 def visit node super @capture_count end |
#visit_SYMBOL(node) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/journey/path/pattern.rb', line 72 def visit_SYMBOL node node = node.to_sym if @matchers.key? node re = /#{@matchers[node]}|/ @capture_count.push((re.match('').length - 1) + (@capture_count.last || 0)) else @capture_count << (@capture_count.last || 0) end end |