Coder Social home page Coder Social logo

flavorjones / ruby-progressbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jfelchner/ruby-progressbar

1.0 3.0 0.0 144 KB

Ruby/ProgressBar is a text progress bar library for Ruby.

License: GNU General Public License v2.0

Ruby 100.00%

ruby-progressbar's Introduction

Ruby/ProgressBar: A Text Progress Bar Library for Ruby

Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate progress with percentage, a progress bar, and estimated remaining time.

Examples

% irb --simple-prompt -r progressbar
>> pbar = ProgressBar.new("test", 100)
=> (ProgressBar: 0/100)
>> 100.times {sleep(0.1); pbar.inc}; pbar.finish
test:          100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
=> nil

>> pbar = ProgressBar.new("test", 100)
=> (ProgressBar: 0/100)
>> (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish
test:           67% |oooooooooooooooooooooooooo              | ETA:  00:00:03

API

  • ProgressBar#new(title, total, out = STDERR)

    Display the initial progress bar and return a ProgressBar object. title specifies the title, and total specifies the total cost of processing. Optional 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.

  • ProgressBar#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.

  • ProgressBar#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.

  • ProgressBar#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.

  • ProgressBar#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.

  • ProgressBar#format=

    Set the format for displaying a progress bar. Default: "%-14s %3d%% %s %s".

  • ProgressBar#format_arguments=

    Set the methods for displaying a progress bar. Default: [:title, :percentage, :bar, :stat].

  • ProgressBar#file_transfer_mode

    Use :stat_for_file_transfer instead of :stat to display transfered bytes and transfer rate.

ReverseProgressBar class is also available. The functionality is identical to ProgressBar 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.


Satoru Takabayashi

ruby-progressbar's People

Contributors

nex3 avatar flavorjones avatar ryanwood avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.