A Ruby terminal progress_bar
Clone or download
Latest commit 313852b Sep 21, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples ProgressBar::WithProgress Aug 8, 2015
lib Release 1.3.0 Sep 21, 2018
profile Profile shelling only once Apr 17, 2011
spec Merge pull request #30 from zverok/master Jan 20, 2016
.gitignore First stab, it pretty much works Apr 7, 2011
.rspec Cleaner tests Apr 10, 2011
.travis.yml And jruby doesn't work anymore, either Nov 25, 2016
Changelog.mkd Release 1.3.0 Sep 21, 2018
Gemfile Use HTTPS for rubygems URL Oct 30, 2017
LICENSE Add License Apr 18, 2011
README.mkd Renamed core_ext Sep 21, 2015
Rakefile Add rake task for specs Mar 14, 2013
progress_bar.gemspec Allow highline 2.x Sep 19, 2018



Build StatusGem Version

ProgressBar is a simple Ruby library for displaying progress of long-running tasks on the console. It is intended to be as simple to use as possible.

NOTE: This project isn't dead! It's just feature complete, and I don't want to keep adding things to it. If you find bugs, please open an Issue, or even better, a Pull Request, and I'll take a look. We at ProgressBar know you have lots of progress bar alternatives, and we thank you for using ProgressBar!


gem install progress_bar


The Easy Way

require 'progress_bar'
bar = ProgressBar.new

100.times do
  sleep 0.1

Produces output like:

[#######################################                           ] [ 59.00%] [00:06]

Note: It may not be exactly like this. I might have changed the default meters between now and when I wrote this readme, and forgotten to update it.

Setting the Max

Usually, the defaults should be fine, the only thing you'll need to tweak is the max.

bar = ProgressBar.new(1000)

Larger Steps

If you want to process several things, and update less often, you can pass a number to #increment!

bar.increment! 42

Picking the meters

By default, ProgressBar will use all available meters (this will probably change). To select which meters you want, and in which order, pass them to the constructor:

bar = ProgressBar.new(100, :bar, :rate, :eta)

Available Meters

  • :bar -- The bar itself, fills empty space with "#"s. Ex: [### ].
  • :counter -- Number of items complete, over the max. Ex: [ 20/100]
  • :percentage -- Percentage of items in the maximum. Ex: [ 42%]
  • :elapsed -- Time elapsed (since the ProgressBar was initialized. Ex: [00:42]
  • :eta -- Estimated Time remaining. Given the rate that items are completed, a guess at how long the rest will take. Ex: [01:30]
  • :rate -- The rate at which items are being completed. Ex: [ 42.42/s]

Run the tests to see examples of all the formats, with different values and maximums.

gem install --development progress_bar
rspec spec/*_spec.rb

Using ProgressBar on Enumerable-alikes.

If you do a lot of progresses, you can shorten your way with this:

class Array
  include ProgressBar::WithProgress


# or any other Enumerable's methods:

(1..1000).to_a.with_progress.select{|i| (i % 2).zero?}

You can include ProgressBar::WithProgress in any class, having methods #count and #each, like some DB datasets and so on.

If you are using progress_bar regularly on plain arrays, you may want to do:

require 'progress_bar/core_ext/enumerable_with_progress'

# it adds each_with_progress/with_progress to Array/Hash/Range

(1..400).with_progress.select{|i| (i % 2).zero?}