Sha256: f4e5e95ae75c838e398d25f57db787123f45f9ae6b4ccca55e454c551ecca512
Contents?: true
Size: 1015 Bytes
Versions: 4
Compression:
Stored size: 1015 Bytes
Contents
require 'enumerator' if (Enumerable::Enumerator rescue false) module Enumerable class Enumerator # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerator.html] Backports.make_block_optional self, :each, :test_on => [42].to_enum def next require 'generator' @generator ||= ::Generator.new(self) raise StopIteration unless @generator.next? @generator.next end unless method_defined? :next def rewind @object.rewind if @object.respond_to? :rewind require 'generator' @generator ||= ::Generator.new(self) @generator.rewind self end unless method_defined? :rewind def with_index(offset = 0) to_enum :with_index, offset unless block_given? each do |*args| yield args.size == 1 ? args[0] : args, index index += 1 end end unless method_defined? :with_index end if const_defined? :Enumerator end end
Version data entries
4 entries across 4 versions & 1 rubygems