Class: DataAnon::Utils::ProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/progress_bar.rb

Direct Known Subclasses

ParallelProgressBar

Instance Method Summary collapse

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
  apply_power_bar_settings  if show_progress_env
end

Instance Method Details

#apply_power_bar_settingsObject


15
16
17
18
19
20
21
22
23
24
# File 'lib/utils/progress_bar.rb', line 15

def apply_power_bar_settings
  @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.barchar = "\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

#closeObject


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