Class: Journey::Path::Pattern::MatchData
- Inherits:
-
Object
- Object
- Journey::Path::Pattern::MatchData
- Defined in:
- lib/journey/path/pattern.rb
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
- #post_match ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(names, offsets, match) ⇒ MatchData
Returns a new instance of MatchData.
137 138 139 140 141 |
# File 'lib/journey/path/pattern.rb', line 137 def initialize names, offsets, match @names = names @offsets = offsets @match = match end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
135 136 137 |
# File 'lib/journey/path/pattern.rb', line 135 def names @names end |
Instance Method Details
#[](x) ⇒ Object
147 148 149 150 |
# File 'lib/journey/path/pattern.rb', line 147 def [] x idx = @offsets[x - 1] + x @match[idx] end |
#captures ⇒ Object
143 144 145 |
# File 'lib/journey/path/pattern.rb', line 143 def captures (length - 1).times.map { |i| self[i + 1] } end |
#length ⇒ Object
152 153 154 |
# File 'lib/journey/path/pattern.rb', line 152 def length @offsets.length end |
#post_match ⇒ Object
156 157 158 |
# File 'lib/journey/path/pattern.rb', line 156 def post_match @match.post_match end |
#to_s ⇒ Object
160 161 162 |
# File 'lib/journey/path/pattern.rb', line 160 def to_s @match.to_s end |