Parent

Files

ProgressBar::Base

Public Class Methods

new(options = {}) click to toggle source
# 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

Public Instance Methods

clear() click to toggle source

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
decrement() click to toggle source

Updating The Bar's Progress

# File lib/ruby-progressbar/base.rb, line 38
def decrement
  update_progress(:decrement)
end
finish() click to toggle source

Stopping The Bar

# File lib/ruby-progressbar/base.rb, line 57
def finish
  with_update { with_progressables(:finish); with_timers(:stop) } unless finished?
end
finished?() click to toggle source
# File lib/ruby-progressbar/base.rb, line 86
def finished?
  @estimated_time.finished? && @bar.finished?
end
increment() click to toggle source
# File lib/ruby-progressbar/base.rb, line 42
def increment
  update_progress(:increment)
end
inspect() click to toggle source
# File lib/ruby-progressbar/base.rb, line 140
def inspect
  "#<ProgressBar:#{progress}/#{total || 'unknown'}>"
end
log(string) click to toggle source
# File lib/ruby-progressbar/base.rb, line 127
def log(string)
  clear
  output.puts string

  update(:force => true) unless stopped?
end
pause() click to toggle source
# File lib/ruby-progressbar/base.rb, line 61
def pause
  with_update { with_timers(:pause) } unless paused?
end
paused?() click to toggle source
Alias for: stopped?
progress=(new_progress) click to toggle source
# File lib/ruby-progressbar/base.rb, line 46
def progress=(new_progress)
  update_progress(:progress=, new_progress)
end
progress_mark=(mark) click to toggle source

UI Updates

# File lib/ruby-progressbar/base.rb, line 97
def progress_mark=(mark)
  with_update { @bar.progress_mark = mark }
end
refresh() click to toggle source
# File lib/ruby-progressbar/base.rb, line 123
def refresh
  update
end
remainder_mark=(mark) click to toggle source
# File lib/ruby-progressbar/base.rb, line 101
def remainder_mark=(mark)
  with_update { @bar.remainder_mark = mark }
end
reset() click to toggle source
# File lib/ruby-progressbar/base.rb, line 73
def reset
  with_update do
    @bar.reset
    with_timers(:reset)
  end
end
resume() click to toggle source
# File lib/ruby-progressbar/base.rb, line 69
def resume
  with_update { with_timers(:resume) } if stopped?
end
start(options = {}) click to toggle source

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
started?() click to toggle source
# File lib/ruby-progressbar/base.rb, line 90
def started?
  @estimated_time.started? && @elapsed_time.started? && @bar.started?
end
stop() click to toggle source
# File lib/ruby-progressbar/base.rb, line 65
def stop
  with_update { with_timers(:stop) } unless stopped?
end
stopped?() click to toggle source
# File lib/ruby-progressbar/base.rb, line 80
def stopped?
  (@estimated_time.stopped? && @elapsed_time.stopped?) || finished?
end
Also aliased as: paused?
title=(title) click to toggle source
# File lib/ruby-progressbar/base.rb, line 105
def title=(title)
  with_update { super }
end
to_s(format_string = nil) click to toggle source
# File lib/ruby-progressbar/base.rb, line 134
def to_s(format_string = nil)
  format_string ||= @format_string

  format(format_string)
end
total=(new_total) click to toggle source
# File lib/ruby-progressbar/base.rb, line 50
def total=(new_total)
  update_progress(:total=, new_total)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.