Sha256: 7645dd77636fb0a269491dd6ddb184e7dc13b9ba7e9ff00052eda7b485e374bf

Contents?: true

Size: 588 Bytes

Versions: 7032

Compression:

Stored size: 588 Bytes

Contents

class   ProgressBar
class   Throttle
  attr_accessor :rate,
                :started_at,
                :stopped_at,
                :timer

  def initialize(options = {})
    self.rate       = options[:throttle_rate] || 0.01
    self.started_at = nil
    self.stopped_at = nil
    self.timer      = options.fetch(:throttle_timer, Timer.new)
  end

  def choke(options = {})
    return unless !timer.started?                        ||
                  options.fetch(:force_update_if, false) ||
                  timer.elapsed_seconds >= rate

    timer.restart

    yield
  end
end
end

Version data entries

7,032 entries across 6,980 versions & 63 rubygems

Version Path
cybrid_api_bank_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_id_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_organization_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_bank_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_id_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_organization_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_bank_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_organization_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_id_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
ory-client-1.16.2 vendor/bundle/ruby/3.1.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
avalara_sdk-24.12.2 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/throttle.rb
cybrid_api_bank_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_organization_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_id_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_bank_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_id_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_organization_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb
cybrid_api_bank_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/throttle.rb