Class: ActionDispatch::Journey::Path::Pattern::RegexpOffsets
- Inherits:
-
Visitors::Visitor
- Object
- Visitors::Visitor
- ActionDispatch::Journey::Path::Pattern::RegexpOffsets
- Defined in:
- lib/action_dispatch/journey/path/pattern.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Visitors::Visitor
Visitors::Visitor::DISPATCH_CACHE
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.
61 62 63 64 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 61 def initialize(matchers) @matchers = matchers @capture_count = [0] end |
Instance Attribute Details
#offsets ⇒ Object (readonly)
Returns the value of attribute offsets.
59 60 61 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 59 def offsets @offsets end |
Instance Method Details
#visit(node) ⇒ Object
66 67 68 69 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 66 def visit(node) super @capture_count end |
#visit_SYMBOL(node) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 71 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 |