Sha256: 7645dd77636fb0a269491dd6ddb184e7dc13b9ba7e9ff00052eda7b485e374bf

Contents?: true

Size: 588 Bytes

Versions: 7076

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,076 entries across 7,024 versions & 64 rubygems

Version Path
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/throttle.rb
kinetic_sdk-0.1.1 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/throttle.rb
progressbar-1.10.1 lib/ruby-progressbar/throttle.rb
ruby-progressbar-1.10.1 lib/ruby-progressbar/throttle.rb
cspeezy_palindrome-0.3.0 path/ruby/2.6.0/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
cspeezy_palindrome-0.2.0 path/ruby/2.6.0/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
cspeezy_palindrome-0.1.0 path/ruby/2.6.0/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
steenfest_palindrome-0.1.2 ruby/2.5/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
steenfest_palindrome-0.1.1b ruby/2.5/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
nullifyable-0.1.0 vendor/bundle/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
dmurphy_palindrome-0.1.0 vendor/cache/ruby/2.3.0/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb
dmurphy_palindrome-0.1.0 vendor/cache/ruby/2.3.0/gems/dmurphy_palindrome-0.1.0/vendor/cache/ruby/2.3.0/gems/ruby-progressbar-1.10.0/lib/ruby-progressbar/throttle.rb