Sha256: 778040f16d5967193f7202b9477c313fded6af1a04a5d5bdfaec5efd0f6044e2

Contents?: true

Size: 543 Bytes

Versions: 38

Compression:

Stored size: 543 Bytes

Contents

class  ProgressBar
module Refinements
module Enumerator
refine ::Enumerator do
  # rubocop:disable Metrics/BlockNesting
  def with_progressbar(options = {}, &block)
    chain = ::Enumerator.new do |yielder|
      progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))

      each do |*args|
        yielder.yield(*args).tap do
          progress_bar.increment
        end
      end
    end

    return chain unless block_given?

    chain.each(&block)
  end
  # rubocop:enable Metrics/BlockNesting
end
end
end
end

Version data entries

38 entries across 38 versions & 5 rubygems

Version Path
kinetic_sdk-5.0.19 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.18 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.17 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.16 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.15 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.14 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.13 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.12 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.11 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.10 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.9 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.8 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.7 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.6 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.5 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.4 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.3 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.2 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.2.beta.4 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb
kinetic_sdk-5.0.2.beta.3 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb