-
-
Notifications
You must be signed in to change notification settings - Fork 132
Example
bjmfactory edited this page Nov 18, 2014
·
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.
Want to play a game of PAC-MAN while you wait for your progress?
ProgressBar.create( :format => '%a %bᗧ%i %p%% %t',
:progress_mark => ' ',
:remainder_mark => '・',
:starting_at => 10)
Becomes PAC-MAN!
Time: --:--:-- ᗧ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ 10% Progress