class ProgressBar::Throttle

Attributes

rate[RW]
started_at[RW]
stopped_at[RW]
timer[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/ruby-progressbar/throttle.rb, line 8
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

Public Instance Methods

choke(options = {}) { || ... } click to toggle source
# File lib/ruby-progressbar/throttle.rb, line 15
def choke(options = {})
  return unless !timer.started?                        ||
                options.fetch(:force_update_if, false) ||
                timer.elapsed_seconds >= rate

  timer.restart

  yield
end