Class: Oniguruma::MultiMatchData

Inherits:
Object
  • Object
show all
Defined in:
lib/oniguruma.rb

Instance Method Summary collapse

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

#eachObject



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

#lengthObject 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

#stringObject



345
346
347
# File 'lib/oniguruma.rb', line 345

def string
   @string.freeze
end

#to_aObject



349
350
351
# File 'lib/oniguruma.rb', line 349

def to_a
   @matches
end