Method: Flex::ProgBar#initialize

Defined in:
lib/flex/prog_bar.rb

#initialize(total_count, batch_size = nil, prefix_message = nil) ⇒ ProgBar

Returns a new instance of ProgBar.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/flex/prog_bar.rb', line 6

def initialize(total_count, batch_size=nil, prefix_message=nil)
  @total_count      = total_count
  @successful_count = 0
  @failed_count     = 0
  @pbar             = ::ProgressBar.new('processing...', total_count)
  @pbar.clear
  @pbar.bar_mark = '|'
  puts '_' * @pbar.send(:get_term_width)
  message = "#{prefix_message}Processing #{total_count} documents"
  message << " in batches of #{batch_size}:" unless batch_size.nil?
  puts message
  @pbar.send(:show)
end