# File lib/ruby-progressbar/components/progressable.rb, line 44 def decrement warn "WARNING: Your progress bar is currently at #{progress} out of #{total} and cannot be decremented. In v2.0.0 this will become a ProgressBar::InvalidProgressError." if progress == 0 self.progress -= 1 unless progress == 0 end
# File lib/ruby-progressbar/components/progressable.rb, line 67 def finish self.progress = self.total end
# File lib/ruby-progressbar/components/progressable.rb, line 34 def finished? self.progress == self.total end
# File lib/ruby-progressbar/components/progressable.rb, line 38 def increment warn "WARNING: Your progress bar is currently at #{progress} out of #{total} and cannot be incremented. In v2.0.0 this will become a ProgressBar::InvalidProgressError." if progress == total self.progress += 1 unless progress == total end
# File lib/ruby-progressbar/components/progressable.rb, line 71 def percentage_completed return 100 if total == 0 return 0 if total.nil? # progress / total * 100 # # Doing this way so we can avoid converting each # number to a float and then back to an integer. # (self.progress * 100 / total).to_i end
# File lib/ruby-progressbar/components/progressable.rb, line 83 def percentage_completed_with_precision format('%5.2f', (progress.to_f * 100.0 / total * 100.0).floor / 100.0) end
# File lib/ruby-progressbar/components/progressable.rb, line 54 def progress=(new_progress) validate_progress(new_progress) @progress = new_progress update_running_average end
# File lib/ruby-progressbar/components/progressable.rb, line 87 def progress_made started? ? self.progress - self.starting_position : 0 end
# File lib/ruby-progressbar/components/progressable.rb, line 50 def reset start :at => self.starting_position end
# File lib/ruby-progressbar/components/progressable.rb, line 23 def start(options = {}) self.running_average = 0 self.progress = self.starting_position = options[:at] || self.progress end
Generated with the Darkfish Rdoc Generator 2.