Class: Enumerator
Defined Under Namespace
Classes: Yielder
Instance Method Summary collapse
Instance Method Details
#initialize_with_optional_block(*arg, &block) ⇒ Object
35 36 37 38 |
# File 'lib/backports/enumerator.rb', line 35 def initialize_with_optional_block(*arg, &block) return initialize_without_optional_block(*arg, &nil) unless arg.empty? # Ruby 1.9 apparently ignores the block if any argument is present initialize_without_optional_block(Yielder.new(&block)) end |
#next ⇒ Object
4 5 6 7 8 9 |
# File 'lib/backports/enumerator.rb', line 4 def next require 'generator' @generator ||= Generator.new(self) raise StopIteration unless @generator.next? @generator.next end |
#rewind ⇒ Object
11 12 13 14 15 16 |
# File 'lib/backports/enumerator.rb', line 11 def rewind require 'generator' @generator ||= Generator.new(self) @generator.rewind self end |