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.



129
130
131
132
133
# File 'lib/action_dispatch/journey/path/pattern.rb', line 129

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

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



127
128
129
# File 'lib/action_dispatch/journey/path/pattern.rb', line 127

def names
  @names
end

Instance Method Details

#[](x) ⇒ Object



139
140
141
142
# File 'lib/action_dispatch/journey/path/pattern.rb', line 139

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

#capturesObject



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

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

#lengthObject



144
145
146
# File 'lib/action_dispatch/journey/path/pattern.rb', line 144

def length
  @offsets.length
end

#post_matchObject



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

def post_match
  @match.post_match
end

#to_sObject



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

def to_s
  @match.to_s
end