Class: Bcome::ProgressBar

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/objects/progress_bar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProgressBar

Returns a new instance of ProgressBar.



7
8
9
# File 'lib/objects/progress_bar.rb', line 7

def initialize
  @count = 0
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



5
6
7
# File 'lib/objects/progress_bar.rb', line 5

def count
  @count
end

Instance Method Details

#increment!Object



11
12
13
# File 'lib/objects/progress_bar.rb', line 11

def increment!
  @count += 1
end

#indicate(config, in_progress) ⇒ Object



19
20
21
22
23
# File 'lib/objects/progress_bar.rb', line 19

def indicate(config, in_progress)
  prefix = in_progress ? config[:prefix].progress : config[:prefix].progress
  bar = prefix + "#{config[:indice] * @count}>" + " (#{@count} #{config[:indice_descriptor]})".progress + "\r"
  print bar
end

#indicate_and_increment!(config, in_progress) ⇒ Object



25
26
27
28
# File 'lib/objects/progress_bar.rb', line 25

def indicate_and_increment!(config, in_progress)
  increment!
  indicate(config, in_progress)
end

#reset!Object



15
16
17
# File 'lib/objects/progress_bar.rb', line 15

def reset!
  @count = 0
end