Module: ProgressBar::Formatter

Included in:
Base
Defined in:
lib/ruby-progressbar/formatter.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#format(new_format_string = DEFAULT_FORMAT_STRING) ⇒ Object



14
15
16
17
# File 'lib/ruby-progressbar/formatter.rb', line 14

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

#initialize(options) ⇒ Object



7
8
9
10
11
12
# File 'lib/ruby-progressbar/formatter.rb', line 7

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

  super(options)
end

#progressObject



23
24
25
# File 'lib/ruby-progressbar/formatter.rb', line 23

def progress
  @bar.progress
end

#title=(title) ⇒ Object



19
20
21
# File 'lib/ruby-progressbar/formatter.rb', line 19

def title=(title)
  @title = title
end

#totalObject



27
28
29
# File 'lib/ruby-progressbar/formatter.rb', line 27

def total
  @bar.total
end