Class: Enumerable::Enumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/backports/1.8.7/enumerator.rb

Instance Method Summary collapse

Instance Method Details

#nextObject

Raises:

  • (StopIteration)


4
5
6
7
8
9
# File 'lib/backports/1.8.7/enumerator.rb', line 4

def next
  require 'generator'
  @generator ||= Generator.new(self)
  raise StopIteration unless @generator.next?
  @generator.next
end

#rewindObject



11
12
13
14
15
16
17
# File 'lib/backports/1.8.7/enumerator.rb', line 11

def rewind
  @object.rewind if @object.respond_to? :rewind
  require 'generator'
  @generator ||= Generator.new(self)
  @generator.rewind
  self
end