Sha256: 4d66097785695e21e7877cd5383b4f74b33dcfe93236580c0336f2dc6c283945

Contents?: true

Size: 822 Bytes

Versions: 2734

Compression:

Stored size: 822 Bytes

Contents

class   ProgressBar
module  Components
class   Rate
  attr_accessor :rate_scale,
                :started_at,
                :stopped_at,
                :timer,
                :progress

  def initialize(options = {})
    self.rate_scale = options[:rate_scale] || lambda { |x| x }
    self.started_at = nil
    self.stopped_at = nil
    self.timer      = options[:timer]
    self.progress   = options[:progress]
  end

  private

  def rate_of_change(format_string = '%i')
    return 0 unless elapsed_seconds > 0

    format_string % scaled_rate
  end

  def rate_of_change_with_precision
    rate_of_change('%.2f')
  end

  def scaled_rate
    rate_scale.call(base_rate)
  end

  def base_rate
    progress.absolute / elapsed_seconds
  end

  def elapsed_seconds
    timer.elapsed_whole_seconds.to_f
  end
end
end
end

Version data entries

2,734 entries across 2,684 versions & 45 rubygems

Version Path
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.3/vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.2/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.3/vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.2/vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.2/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.2/vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.4 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.3/vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.2 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.2 vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.1 vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.1 vendor/cache/ruby/2.7.0/gems/paynow_sdk-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
paynow_sdk-0.1.0 vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
kinetic_sdk-5.0.8 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb
chikari_palindrome-0.1.0 vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
chikari_palindrome-0.1.0 vendor/cache/ruby/2.7.0/gems/chikari_palindrome-0.1.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb
kinetic_sdk-5.0.7 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb
kinetic_sdk-5.0.6 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb
kinetic_sdk-5.0.5 gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/components/rate.rb