Sha256: f989f8cc88fba9a4dcee5250314a5129fb92a81b993c8e9a448a5a3ac77ea447

Contents?: true

Size: 717 Bytes

Versions: 4003

Compression:

Stored size: 717 Bytes

Contents

class  ProgressBar
module Refinements
module Enumerator
  ARITY_ERROR_MESSAGE = 'Only two arguments allowed to be passed to ' \
                        'with_progressbar (item, progress_bar)'.freeze

  refine ::Enumerator do
    def with_progressbar(options = {}, &block)
      progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))

      each do |item|
        progress_bar.increment

        next unless block

        yielded_args = []
        yielded_args << item         if block.arity > 0
        yielded_args << progress_bar if block.arity > 1

        fail ::ArgumentError, ARITY_ERROR_MESSAGE if block.arity > 2

        yield(*yielded_args)
      end
    end
  end
end
end
end

Version data entries

4,003 entries across 4,003 versions & 27 rubygems

Version Path
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb
cybrid_api_id_ruby-0.123.2 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/refinements/progress_enumerator.rb