0.01
No commit activity in last 3 years
No release in over 3 years
Render custom textual progress bars with a simple little API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
 Project Readme

bar-of-progress

Build Status Code Climate

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

API

Default progress bars

require 'bar-of-progress'

bar = BarOfProgress.new #=> defaults to completeness == "100"  

bar.progress #=> "[◌◌◌◌◌◌◌◌◌◌]"

bar.progress(50) #=> "[●●●●●◌◌◌◌◌]"

bar.progress(49) #=> "[●●●●◍◌◌◌◌◌]"

Custom progress bars

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) #=> "(■■■▤□□□□□□□□□□)"