Sha256: 93063f896b19bce24ac567b1c5ec9ebe316254a602b380d1232e9caffa3b1cdc

Contents?: true

Size: 503 Bytes

Versions: 19

Compression:

Stored size: 503 Bytes

Contents

Enumerator = Enumerable::Enumerator unless Object.const_defined? :Enumerator # For 1.8.x

unless Enumerator.respond_to?(:produce)
  require 'backports/tools/arguments'

  class Enumerator
    def self.produce(initial = Backports::Undefined)
      raise ArgumentError, 'no block given' unless block_given?

      Enumerator.new do |y|
        val = initial == Backports::Undefined ? yield() : initial

        loop do
          y << val
          val = yield(val)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.24.1 lib/backports/2.7.0/enumerator/produce.rb
backports-3.24.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.23.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.22.1 lib/backports/2.7.0/enumerator/produce.rb
backports-3.22.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.21.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.20.2 lib/backports/2.7.0/enumerator/produce.rb
backports-3.20.1 lib/backports/2.7.0/enumerator/produce.rb
backports-3.20.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.19.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.18.2 lib/backports/2.7.0/enumerator/produce.rb
backports-3.18.1 lib/backports/2.7.0/enumerator/produce.rb
backports-3.18.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.17.2 lib/backports/2.7.0/enumerator/produce.rb
backports-3.17.1 lib/backports/2.7.0/enumerator/produce.rb
backports-3.17.0 lib/backports/2.7.0/enumerator/produce.rb
backports-3.16.1 lib/backports/2.7.0/enumerator/produce.rb
backports-3.16.0 lib/backports/2.7.0/enumerator/produce.rb