______ _______ _______ _______ | __ \_ _| | |_ _| | < | | | | |_| |_ |___|__| |___| |_______|_______|
This gem goal is to provide TUI eye candy for ruby.
For now, we got:
-
From Ruby/ProgressBar by Satoru Takabayashi
Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate progress with percentage, a progress bar, and estimated remaining time. This fork changes the api and adds some methods.
Examples¶ ↑
pbar = Rtui::Progress.new("test", 100) 100.times {sleep(0.1); pbar.inc}; pbar.finish test: 100% |===============================================| Time: 00:00:10 pbar = Rtui::Progress.new("test", 100, :components => [:bar, :percentage]) 100.times {sleep(0.1); pbar.inc}; pbar.finish |====================================================================| 100% pbar = Progress.new("test", 100, :components => [:spinner, :subject, :percentage]) 100.times { |i| sleep(0.1); pbar.subject = "Iteration #{i}.."; pbar.inc}; pbar.finish \ Iteration 68 68% pbar = Progress.new("foo", 100, :bar => "o", :components => [:pong, :percentage]) (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish | o | 67%
Install¶ ↑
sudo gem install rtui
API¶ ↑
Progress#new (title, total, *options)¶ ↑
Display the initial progress bar and return a ProgressBar object. ((|title|)) specifies the title, and ((|total|)) specifies the total cost of processing. Options parameter ((|:out|)) specifies the output IO. The display of the progress bar is updated when one or more percent is proceeded or one or more seconds are elapsed from the previous display.
Options:¶ ↑
{ :bar => "=", :out => STDERR, :components => [ :title, :bar, :spinner, :subject, :pong, :percentage, :stat ]}
Progress#inc (step = 1)¶ ↑
Increase the internal counter by ((|step|)) and update the display of the progress bar. Display the estimated remaining time on the right side of the bar. The counter does not go beyond the ((|total|)).
Progress#set (count)¶ ↑
Set the internal counter to ((|count|)) and update the display of the progress bar. Display the estimated remaining time on the right side of the bar. Raise if ((|count|)) is a negative number or a number more than the ((|total|)).
Progress#subject (subject)¶ ↑
Set the bar current subject.
Progress#finish¶ ↑
Stop the progress bar and update the display of progress bar. Display the elapsed time on the right side of the bar. The progress bar always stops at 100 % by the method.
Progress#halt¶ ↑
Stop the progress bar and update the display of progress bar. Display the elapsed time on the right side of the bar. The progress bar stops at the current percentage by the method.
Progress#format_arguments=¶ ↑
Set the methods for displaying a progress bar. Default: [:title, :percentage, :bar, :stat].
Progress#file_transfer_mode¶ ↑
Use :stat_for_file_transfer instead of :stat to display transfered bytes and transfer rate.
ReverseProgress class is also available. The functionality is identical to Progress but the direction of the progress bar is just opposite.
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.
LICENSE:¶ ↑
Copyright (C) 2008
Original Gem¶ ↑
* http://namazu.org/~satoru/ruby-progressbar/ruby-progressbar-0.9.tar.gz * http://cvs.namazu.org/ruby-progressbar Satoru Takabayashi http://namazu.org/~satoru Copyright (C) 2001-2005 Satoru Takabayashi <satoru@namazu.org> All rights reserved. This is free software with ABSOLUTELY NO WARRANTY.
You can redistribute it and/or modify it under the terms of Ruby’s license.