Ruby/ProgressBar is a text progress bar library for Ruby.
Pull request Compare This branch is even with leonid-shevtsov:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
GPL_LICENSE
README.md
RUBY_LICENSE
ruby-progressbar.gemspec
test.rb

README.md

ruby/progressbar

Ruby/ProgressBar is a text progress bar library for Ruby.

It can indicate progress with percentage, a progress bar, and estimated remaining time.

Documentation is available at rdoc.info

Examples

Basic functionality:

% irb --simple-prompt -r progressbar
>> pbar = ProgressBar.new("test", 100)
=> (ProgressBar: 0/100)
>> 100.times {sleep(0.1); pbar.inc}; pbar.finish
test:          100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
=> nil

Set position directly:

>> pbar = ProgressBar.new("test", 100)
=> (ProgressBar: 0/100)
>> (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish
test:           67% |oooooooooooooooooooooooooo              | ETA:  00:00:03

Block mode:

>> ProgressBar.block('test',100) do |pbar|
>>   100.times { sleep(0.1); pbar.inc }
>> end

Even simpler:

>> (1..100).to_a.each_with_progressbar('test') do
>>   sleep 0.1
>> end

Installation

gem install ruby-progressbar

Limitations

Since the progress is calculated by the proportion to the total cost of processing, Ruby/ProgressBar cannot be used if the total cost of processing is unknown in advance. Moreover, the estimation of remaining time cannot be accurately performed if the progress does not flow uniformly.


Satoru Takabayashi

Cleaned up by Leonid Shevtsov