Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Example

Jeff Felchner edited this page Jul 13, 2016 · 7 revisions

If you would like a bar with the elapsed time on the left and the percentage complete followed by the title on the right, you'd do this:

ProgressBar.create(:format => '%a %B %p%% %t')

Which will output something like this:

Time: --:--:-- 0% Progress

Hard to see where the bar is? Just add your own end caps, whatever you'd like. Like so:

ProgressBar.create(:format => '%a <%B> %p%% %t')

Becomes:

Time: --:--:-- < > 0% Progress

Want to put an end cap on your bar? Nothing special, just use the bar flag %b combined with the incomplete space flag %i like so:

ProgressBar.create(:format => '%a |%b>>%i| %p%% %t', :starting_at => 10)

Becomes:

Time: --:--:-- |====>> | 10% Progress

Notice that the absolute length doesn't get any longer, the bar just shrinks to fill the remaining space.

One more variant for long tasks with high amount of items:

ProgressBar.create format: "%a %e %P% Processed: %c from %C"
Time: 00:43:54 ETA: 00:37:39 53.84% Processed: 44999 from 83577

PAC-MAN

Want to play a game of PAC-MAN while you wait for your progress?

ProgressBar.create( :format => "%a %b\u{15E7}%i %p%% %t",
 :progress_mark => ' ',
 :remainder_mark => "\u{FF65}",
 :starting_at => 10)

Becomes PAC-MAN!

Time: --:--:-- ᗧ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ 10% Progress

Pacman Animation

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /