Class: HP::Cloud::Progress

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

Instance Method Summary collapse

Constructor Details

#initialize(name, siz) ⇒ Progress

Returns a new instance of Progress.



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

def initialize(name, siz)
  siz = 1 if siz <= 0
  args = { :title => File.basename(name), :total => siz}
  begin
    @pbar = ProgressBar.create(args)
  rescue
  end
end

Instance Method Details

#finishObject



45
46
47
48
49
50
# File 'lib/hpcloud/progress.rb', line 45

def finish
  begin
    @pbar.finish if @pbar.progress < @pbar.total
  rescue
  end
end

#increment(siz) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/hpcloud/progress.rb', line 36

def increment(siz)
  return if siz.nil?
  return if siz == 0
  begin
    @pbar.progress += siz
  rescue
  end
end