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.1"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BarOfProgress

Returns a new instance of BarOfProgress.



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

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

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

Instance Method Details

#progress(amount = 0) ⇒ Object



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

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