Class: Squib::Progress Private

Inherits:
Object
  • Object
show all
Defined in:
lib/squib/progress.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A facade that handles (or doesn’t) the progress bar on the console

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled) ⇒ Progress

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Progress.



22
23
24
# File 'lib/squib/progress.rb', line 22

def initialize(enabled)
  @enabled = enabled
end

Instance Attribute Details

#enabledObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
# File 'lib/squib/progress.rb', line 20

def enabled
  @enabled
end

Instance Method Details

#start(title = '', total = 100, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
30
31
32
33
34
# File 'lib/squib/progress.rb', line 26

def start(title='', total=100, &block)
  if @enabled
    @bar = ProgressBar.create(title: title, total: total, format: '%t <%B> %p%% %a')
    yield(@bar)
    @bar.finish
  else
    yield(Squib::DoNothing.new)
  end
end