Parent

Files

Class/Module Index [+]

Quicksearch

Console::ProgressBar

Public Class Methods

new(title, total, out = STDERR) click to toggle source
# File lib/contrib/progressbar.rb, line 37
def initialize(title, total, out = STDERR)
  @title = title
  @total = total
  @out = out
  @bar_length = 80
  @bar_mark = "o"
  @total_overflow = true
  @current = 0
  @previous = 0
  @is_finished = false
  @start_time = Time.now
  @format = "%-14s %3d%% %s %s"
  @format_arguments = [:title, :percentage, :bar, :stat]
  show_progress
end

Public Instance Methods

bar_mark=(mark) click to toggle source
# File lib/contrib/progressbar.rb, line 184
def bar_mark= (mark)
  @bar_mark = String(mark)[0..0]
end
file_transfer_mode() click to toggle source
# File lib/contrib/progressbar.rb, line 180
def file_transfer_mode
  @format_arguments = [:title, :percentage, :bar, :stat_for_file_transfer]  
end
finish() click to toggle source
# File lib/contrib/progressbar.rb, line 200
def finish
  @current = @total
  @is_finished = true
  show_progress
end
format=(format) click to toggle source
# File lib/contrib/progressbar.rb, line 192
def format= (format)
  @format = format
end
format_arguments=(arguments) click to toggle source
# File lib/contrib/progressbar.rb, line 196
def format_arguments= (arguments)
  @format_arguments = arguments
end
halt() click to toggle source
# File lib/contrib/progressbar.rb, line 206
def halt
  @is_finished = true
  show_progress
end
inc(step = 1) click to toggle source
# File lib/contrib/progressbar.rb, line 226
def inc (step = 1)
  @current += step
  @current = @total if @current > @total
  show_progress
  @previous = @current
end
inspect() click to toggle source
# File lib/contrib/progressbar.rb, line 233
def inspect
  "(ProgressBar: #{@current}/#{@total})"
end
set(count) click to toggle source
# File lib/contrib/progressbar.rb, line 211
def set (count)
  if count < 0
    raise "invalid count less than zero: #{count}"
  elsif count > @total
    if @total_overflow
      @total = count + 1
    else
      raise "invalid count greater than total: #{count}"
    end
  end
  @current = count
  show_progress
  @previous = @current
end
total_overflow=(boolv) click to toggle source
# File lib/contrib/progressbar.rb, line 188
def total_overflow= (boolv)
  @total_overflow = boolv ? true : false
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.