# File lib/progress_bar/base.rb, line 9 def initialize(*args) options = args.empty? ? {} : backwards_compatible_args_to_options_conversion(args) self.output = options[:output] || DEFAULT_OUTPUT_STREAM super(options) @bar = Components::Bar.new(options) @estimated_time = Components::EstimatedTimer.new(options) @elapsed_time = Components::ElapsedTimer.new start :at => options[:starting_at] end
Output
# File lib/progress_bar/base.rb, line 100 def clear output.print clear_string end
Updating The Bar's Progress
# File lib/progress_bar/base.rb, line 38 def decrement with_update { with_progressables(:decrement) } end
Stopping The Bar
# File lib/progress_bar/base.rb, line 53 def finish with_update { with_progressables(:finish) } end
# File lib/progress_bar/base.rb, line 82 def finished? @bar.progress == @bar.total end
# File lib/progress_bar/base.rb, line 42 def increment with_update { with_progressables(:increment) } end
# File lib/progress_bar/base.rb, line 114 def inspect "#<ProgressBar:#{progress}/#{total}>" end
# File lib/progress_bar/base.rb, line 57 def pause with_update { with_timers(:pause) } end
# File lib/progress_bar/base.rb, line 46 def progress=(new_progress) with_update { with_progressables(:progress=, new_progress) } end
UI Updates
# File lib/progress_bar/base.rb, line 89 def progress_mark=(mark) with_update { @bar.progress_mark = mark } end
# File lib/progress_bar/base.rb, line 104 def refresh update end
# File lib/progress_bar/base.rb, line 69 def reset with_update do @bar.reset with_timers(:reset) end end
# File lib/progress_bar/base.rb, line 65 def resume with_update { with_timers(:resume) } end
Starting The Bar
# File lib/progress_bar/base.rb, line 26 def start(options = {}) clear with_update do with_progressables(:start, options) @elapsed_time.start end end
# File lib/progress_bar/base.rb, line 61 def stop with_update { with_timers(:stop) } end
# File lib/progress_bar/base.rb, line 76 def stopped? @estimated_time.stopped? && @elapsed_time.stopped? end
# File lib/progress_bar/base.rb, line 93 def title=(title) with_update { super } end
# File lib/progress_bar/base.rb, line 108 def to_s(format_string = nil) format_string ||= @format_string format(format_string) end