Class: Oniguruma::MultiMatchData
- Inherits:
-
Object
- Object
- Oniguruma::MultiMatchData
- Defined in:
- lib/oniguruma.rb
Instance Method Summary collapse
- #[](value1, value2 = nil) ⇒ Object
- #begin(index) ⇒ Object
- #each ⇒ Object
- #end(index) ⇒ Object
-
#initialize(string, matches, positions) ⇒ MultiMatchData
constructor
A new instance of MultiMatchData.
- #length ⇒ Object (also: #size)
- #offset(index) ⇒ Object
- #position(index) ⇒ Object
- #string ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(string, matches, positions) ⇒ MultiMatchData
Returns a new instance of MultiMatchData.
310 311 312 313 314 |
# File 'lib/oniguruma.rb', line 310 def initialize( string, matches, positions ) @matches = matches @positions = positions @string = string end |
Instance Method Details
#[](value1, value2 = nil) ⇒ Object
320 321 322 323 324 325 326 |
# File 'lib/oniguruma.rb', line 320 def [] ( value1, value2 = nil ) unless value2 @matches[value1] else @matches[value1, value2] end end |
#begin(index) ⇒ Object
328 329 330 |
# File 'lib/oniguruma.rb', line 328 def begin index @matches[index].begin(0) + @positions[index] end |
#each ⇒ Object
353 354 355 356 357 |
# File 'lib/oniguruma.rb', line 353 def each @matches.size.times do |i| yield @matches[i], @positions[i] end end |
#end(index) ⇒ Object
332 333 334 |
# File 'lib/oniguruma.rb', line 332 def end index @matches[index].end(0) + @positions[index] end |
#length ⇒ Object Also known as: size
336 337 338 |
# File 'lib/oniguruma.rb', line 336 def length @matches.size end |
#offset(index) ⇒ Object
341 342 343 |
# File 'lib/oniguruma.rb', line 341 def offset index [self.begin(index), self.end(index) ] end |
#position(index) ⇒ Object
316 317 318 |
# File 'lib/oniguruma.rb', line 316 def position index @positions[index] end |
#string ⇒ Object
345 346 347 |
# File 'lib/oniguruma.rb', line 345 def string @string.freeze end |
#to_a ⇒ Object
349 350 351 |
# File 'lib/oniguruma.rb', line 349 def to_a @matches end |