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



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

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
13
# File 'lib/ruby-progressbar/formatter.rb', line 7

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

  super(options)
end

#progressObject



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

def progress
  @bar.progress
end

#title=(title) ⇒ Object



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

def title=(title)
  @title = title
end

#totalObject



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

def total
  @bar.total
end