Class: ActionDispatch::Journey::Path::Pattern::MatchData

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/journey/path/pattern.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(names, offsets, match) ⇒ MatchData

Returns a new instance of MatchData.



136
137
138
139
140
# File 'lib/action_dispatch/journey/path/pattern.rb', line 136

def initialize(names, offsets, match)
  @names   = names
  @offsets = offsets
  @match   = match
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



134
135
136
# File 'lib/action_dispatch/journey/path/pattern.rb', line 134

def names
  @names
end

Instance Method Details

#[](x) ⇒ Object



146
147
148
149
# File 'lib/action_dispatch/journey/path/pattern.rb', line 146

def [](x)
  idx = @offsets[x - 1] + x
  @match[idx]
end

#capturesObject



142
143
144
# File 'lib/action_dispatch/journey/path/pattern.rb', line 142

def captures
  (length - 1).times.map { |i| self[i + 1] }
end

#lengthObject



151
152
153
# File 'lib/action_dispatch/journey/path/pattern.rb', line 151

def length
  @offsets.length
end

#post_matchObject



155
156
157
# File 'lib/action_dispatch/journey/path/pattern.rb', line 155

def post_match
  @match.post_match
end

#to_sObject



159
160
161
# File 'lib/action_dispatch/journey/path/pattern.rb', line 159

def to_s
  @match.to_s
end