class ProgressBar::Projectors::SmoothedAverage
Constants
- DEFAULT_BEGINNING_POSITION
- DEFAULT_STRENGTH
Attributes
Public Class Methods
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 56 def self.calculate(current_projection, new_value, rate) (new_value * (1.0 - rate)) + (current_projection * rate) end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 11 def initialize(options = {}) self.samples = [] self.projection = 0.0 self.strength = options[:strength] || DEFAULT_STRENGTH start(:at => DEFAULT_BEGINNING_POSITION) end
Public Instance Methods
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 24 def decrement self.progress -= 1 end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 28 def increment self.progress += 1 end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 52 def none? projection.zero? end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 32 def progress samples[1] end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 42 def progress=(new_progress) samples[1] = new_progress self.projection = \ self.class.calculate( @projection, absolute, strength ) end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 38 def reset start(:at => samples[0]) end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 19 def start(options = {}) self.projection = 0.0 self.progress = samples[0] = (options[:at] || progress) end
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 36 def total=(_new_total); end
Private Instance Methods
Source
# File lib/ruby-progressbar/projectors/smoothed_average.rb, line 66 def absolute samples[1] - samples[0] end