Class: BarOfProgress

Inherits:
Object
  • Object
show all
Defined in:
lib/bar-of-progress.rb,
lib/bar_of_progress/version.rb

Defined Under Namespace

Classes: Output

Constant Summary collapse

DEFAULTS =
{
  :total => 100,
  :length => 10,
  :braces => %w{[ ]},
  :complete_indicator => "",
  :partial_indicator => "",
  :incomplete_indicator => "",
  :precision => 20
}
VERSION =
"0.1.3"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BarOfProgress

Returns a new instance of BarOfProgress.



18
19
20
21
22
23
24
# File 'lib/bar-of-progress.rb', line 18

def initialize(options = {})
  @options = DEFAULTS.merge(options)

  #massage data because eww.
  @options[:total] = to_d(@options[:total])
  @options[:length] = @options[:length].to_i
end

Instance Method Details

#progress(amount = 0) ⇒ Object



26
27
28
29
# File 'lib/bar-of-progress.rb', line 26

def progress(amount = 0)
  bubbles = clamped_bubbles_for(amount)
  Output.new(bubbles.floor, partial_bubbles_for(bubbles), @options).to_s
end