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(format_string = DEFAULT_FORMAT_STRING) ⇒ Object



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

def format(format_string = DEFAULT_FORMAT_STRING)
  @format_string = format_string
  @format        = ProgressBar::Format::Base.new(format_string)

  process
end

#initialize(options) ⇒ Object



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

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

  super(options)
end

#progressObject



24
25
26
# File 'lib/progress_bar/formatter.rb', line 24

def progress
  @bar.progress
end

#title=(title) ⇒ Object



20
21
22
# File 'lib/progress_bar/formatter.rb', line 20

def title=(title)
  @title = title
end

#totalObject



28
29
30
# File 'lib/progress_bar/formatter.rb', line 28

def total
  @bar.total
end