Sha256: c8d5526fd04984f69280c85634bb74be5e29d4a5b68eae97f25390f81e17e1ba
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
require 'tty/progressbar' require 'colorize' module Chronicle module ETL module Utils class ProgressBar FORMAT_WITH_TOTAL = [ ':bar ', ':percent'.light_white, ' | '.light_black, ':current'.light_white, '/'.light_black, ':total'.light_white, ' ('.light_black, 'ELAPSED:'.light_black, ':elapsed'.light_white, ' | ETA:'.light_black, ':eta'.light_white, ' | RATE: '.light_black, ':mean_rate'.light_white, '/s) '.light_black ].join.freeze FORMAT_WITHOUT_TOTAL = [ ':current'.light_white, '/'.light_black, '???'.light_white, ' ('.light_black, 'ELAPSED:'.light_black, ':elapsed'.light_white, ' | ETA:'.light_black, '??:??'.light_white, ' | RATE: '.light_black, ':mean_rate'.light_white, '/s) '.light_black ].join.freeze def initialize(title: 'Loading', total:) opts = { clear: true, complete: '▓'.light_blue, incomplete: '░'.blue, frequency: 10 } if total opts[:total] = total format_str = "#{title} #{FORMAT_WITH_TOTAL}" @pbar = TTY::ProgressBar.new(FORMAT_WITH_TOTAL, opts) else format_str = "#{title} #{FORMAT_WITHOUT_TOTAL}" opts[:no_width] = true end @pbar = TTY::ProgressBar.new(format_str, opts) @pbar.resize end def increment @pbar.advance(1) end def log(message) @pbar.log message.inspect end def finish @pbar.finish end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems