Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/searls/bar-of-progress
One of the hardest problems in computer science: Solved ✅
https://github.com/searls/bar-of-progress
Last synced: 3 months ago
JSON representation
One of the hardest problems in computer science: Solved ✅
- Host: GitHub
- URL: https://github.com/searls/bar-of-progress
- Owner: searls
- License: mit
- Created: 2014-08-21T02:23:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-02T01:46:44.000Z (over 8 years ago)
- Last Synced: 2024-10-19T23:33:31.905Z (3 months ago)
- Language: Ruby
- Size: 20.5 KB
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# bar-of-progress
[![Build Status](https://travis-ci.org/searls/bar-of-progress.svg?branch=master)](https://travis-ci.org/searls/bar-of-progress) [![Code Climate](https://codeclimate.com/github/searls/bar-of-progress/badges/gpa.svg)](https://codeclimate.com/github/searls/bar-of-progress)
Everyone knows that progress bars are one of the hard, unsolved problems of computer science, so I decided to give it a shot.
![xkcd rocks](http://imgs.xkcd.com/comics/estimation.png)
## API
### Default progress bars
``` ruby
require 'bar-of-progress'bar = BarOfProgress.new #=> defaults to completeness == "100"
bar.progress #=> "[◌◌◌◌◌◌◌◌◌◌]"
bar.progress(50) #=> "[●●●●●◌◌◌◌◌]"
bar.progress(49) #=> "[●●●●◍◌◌◌◌◌]"
```### Custom progress bars
``` ruby
require 'bar-of-progress'bar = BarOfProgress.new(
:total => 115.5, #=> default (will be converted to BigDecimal): 100
:length => 14, #=> default (will be converted to Fixnum): 10
:braces => %w{( )}, #=> default: ["[", "]"]
:complete_indicator => "■", #=> default: "●"
:partial_indicator => "▤", #=> default: "◍"
:incomplete_indicator => "□", #=> default: "◌"
:precision => 18 #=> default (determines what is considered 'partial'): 20
)bar.progress(30) #=> "(■■■▤□□□□□□□□□□)"
```