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