| Class | Commander::UI::ProgressBar |
| In: |
lib/commander/user_interaction.rb
|
| Parent: | Object |
Terminal progress bar utility. In its most basic form requires that the developer specifies when the bar should be incremented. Note that a hash of tokens may be passed to increment, (or returned when using Object#progress).
uris = %w(
http://vision-media.ca
http://yahoo.com
http://google.com
)
bar = Commander::UI::ProgressBar.new uris.length, options
threads = []
uris.each do |uri|
threads << Thread.new do
begin
res = open uri
bar.increment :uri => uri
rescue Exception => e
bar.increment :uri => "#{uri} failed"
end
end
end
threads.each { |t| t.join }
The Object method progress is also available:
progress uris, :width => 10 do |uri|
res = open uri
{ :uri => uri } # Can now use :uri within :format option
end
Creates a new progress bar.
:title Title, defaults to "Progress" :width Width of :progress_bar :progress_str Progress string, defaults to "=" :incomplete_str Incomplete bar string, defaults to '.' :format Defaults to ":title |:progress_bar| :percent_complete% complete " :tokens Additional tokens replaced within the format string :complete_message Defaults to "Process complete"
:title :percent_complete :progress_bar :step :steps_remaining :total_steps :time_elapsed :time_remaining