Class: ActionDispatch::Journey::Path::Pattern::MatchData
- Inherits:
-
Object
- Object
- ActionDispatch::Journey::Path::Pattern::MatchData
- Defined in:
- lib/action_dispatch/journey/path/pattern.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #[](x) ⇒ Object
- #captures ⇒ Object
-
#initialize(names, offsets, match) ⇒ MatchData
constructor
A new instance of MatchData.
- #length ⇒ Object
- #named_captures ⇒ Object
- #post_match ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(names, offsets, match) ⇒ MatchData
Returns a new instance of MatchData.
127 128 129 130 131 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 127 def initialize(names, offsets, match) @names = names @offsets = offsets @match = match end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
125 126 127 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 125 def names @names end |
Instance Method Details
#[](x) ⇒ Object
141 142 143 144 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 141 def [](x) idx = @offsets[x - 1] + x @match[idx] end |
#captures ⇒ Object
133 134 135 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 133 def captures Array.new(length - 1) { |i| self[i + 1] } end |
#length ⇒ Object
146 147 148 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 146 def length @offsets.length end |
#named_captures ⇒ Object
137 138 139 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 137 def named_captures @names.zip(captures).to_h end |
#post_match ⇒ Object
150 151 152 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 150 def post_match @match.post_match end |
#to_s ⇒ Object
154 155 156 |
# File 'lib/action_dispatch/journey/path/pattern.rb', line 154 def to_s @match.to_s end |