Module: ProgressBar::Formatter

Included in:
Base
Defined in:
lib/progress_bar/formatter.rb

Constant Summary collapse

DEFAULT_FORMAT_STRING =
'%t: |%B|'
DEFAULT_TITLE =
'Progress'

Instance Method Summary collapse

Instance Method Details

#format(new_format_string = DEFAULT_FORMAT_STRING) ⇒ Object



13
14
15
16
# File 'lib/progress_bar/formatter.rb', line 13

def format(new_format_string = DEFAULT_FORMAT_STRING)
  self.format_string = new_format_string
  @format.process(self)
end

#initialize(options) ⇒ Object



6
7
8
9
10
11
# File 'lib/progress_bar/formatter.rb', line 6

def initialize(options)
  self.format_string = options[:format] || DEFAULT_FORMAT_STRING
  @title             = options[:title]  || DEFAULT_TITLE

  super(options)
end

#progressObject



22
23
24
# File 'lib/progress_bar/formatter.rb', line 22

def progress
  @bar.progress
end

#title=(title) ⇒ Object



18
19
20
# File 'lib/progress_bar/formatter.rb', line 18

def title=(title)
  @title = title
end

#totalObject



26
27
28
# File 'lib/progress_bar/formatter.rb', line 26

def total
  @bar.total
end