Object
# File lib/ruby-progressbar/base.rb, line 8 def initialize(options = {}) self.output = options[:output] || DEFAULT_OUTPUT_STREAM autostart = options.fetch(:autostart, true) super(options) @bar = Components::Bar.new(options) @rate = Components::Rate.new(options) @estimated_time = Components::EstimatedTimer.new(options) @elapsed_time = Components::ElapsedTimer.new @throttle = Components::Throttle.new(options) start :at => options[:starting_at] if autostart end
Output
# File lib/ruby-progressbar/base.rb, line 112 def clear self.last_update_length = 0 if output.tty? output.print clear_string output.print "\r" else output.print "\n" end end
Updating The Bar's Progress
# File lib/ruby-progressbar/base.rb, line 38 def decrement update_progress(:decrement) end
Stopping The Bar
# File lib/ruby-progressbar/base.rb, line 57 def finish with_update { with_progressables(:finish); with_timers(:stop) } unless finished? end
# File lib/ruby-progressbar/base.rb, line 86 def finished? @estimated_time.finished? && @bar.finished? end
# File lib/ruby-progressbar/base.rb, line 42 def increment update_progress(:increment) end
# File lib/ruby-progressbar/base.rb, line 140 def inspect "#<ProgressBar:#{progress}/#{total || 'unknown'}>" end
# File lib/ruby-progressbar/base.rb, line 127 def log(string) clear output.puts string update(:force => true) unless stopped? end
# File lib/ruby-progressbar/base.rb, line 61 def pause with_update { with_timers(:pause) } unless paused? end
# File lib/ruby-progressbar/base.rb, line 46 def progress=(new_progress) update_progress(:progress=, new_progress) end
UI Updates
# File lib/ruby-progressbar/base.rb, line 97 def progress_mark=(mark) with_update { @bar.progress_mark = mark } end
# File lib/ruby-progressbar/base.rb, line 123 def refresh update end
# File lib/ruby-progressbar/base.rb, line 101 def remainder_mark=(mark) with_update { @bar.remainder_mark = mark } end
# File lib/ruby-progressbar/base.rb, line 73 def reset with_update do @bar.reset with_timers(:reset) end end
# File lib/ruby-progressbar/base.rb, line 69 def resume with_update { with_timers(:resume) } if stopped? end
Starting The Bar
# File lib/ruby-progressbar/base.rb, line 26 def start(options = {}) clear with_update do with_progressables(:start, options) with_timers(:start) end end
# File lib/ruby-progressbar/base.rb, line 90 def started? @estimated_time.started? && @elapsed_time.started? && @bar.started? end
# File lib/ruby-progressbar/base.rb, line 65 def stop with_update { with_timers(:stop) } unless stopped? end
# File lib/ruby-progressbar/base.rb, line 80 def stopped? (@estimated_time.stopped? && @elapsed_time.stopped?) || finished? end
# File lib/ruby-progressbar/base.rb, line 105 def title=(title) with_update { super } end
Generated with the Darkfish Rdoc Generator 2.