Class: DataAnon::Utils::ProgressBar
- Inherits:
-
Object
- Object
- DataAnon::Utils::ProgressBar
- Defined in:
- lib/utils/progress_bar.rb
Direct Known Subclasses
Instance Method Summary collapse
- #apply_power_bar_settings ⇒ Object
- #close ⇒ Object
-
#initialize(table_name, total) ⇒ ProgressBar
constructor
A new instance of ProgressBar.
- #show(index) ⇒ Object
Constructor Details
#initialize(table_name, total) ⇒ ProgressBar
Returns a new instance of ProgressBar.
8 9 10 11 12 13 |
# File 'lib/utils/progress_bar.rb', line 8 def initialize table_name, total @total = total @table_name = table_name @power_bar = PowerBar.new if show_progress_env if show_progress_env end |
Instance Method Details
#apply_power_bar_settings ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/utils/progress_bar.rb', line 15 def @power_bar.settings.tty.finite.template.main = \ "${<msg>} ${<bar> }\e[0m${<rate>/s} \e[33;1m${<percent>%} " + "\e[36;1m${<elapsed>}\e[31;1m${ ETA: <eta>}" @power_bar.settings.tty.finite.template.padchar = "\e[0m\u2589" @power_bar.settings.tty.finite.template. = "\e[34;1m\u2589" @power_bar.settings.tty.finite.template.exit = "\e[?25h\e[0m" # clean up after us @power_bar.settings.tty.finite.template.close = "\e[?25h\e[0m\n" # clean up after us @power_bar.settings.tty.finite.output = Proc.new { |s| $stderr.print s } end |
#close ⇒ Object
32 33 34 |
# File 'lib/utils/progress_bar.rb', line 32 def close @power_bar.close if @power_bar end |
#show(index) ⇒ Object
26 27 28 29 30 |
# File 'lib/utils/progress_bar.rb', line 26 def show index if show_progress? index show_progress index end end |