Class: Gem::CobblerFace::DownloadReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/shoes/cobbler.rb

Overview

ProgressReporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prog, status, size, initial_message, terminal_message = "complete") ⇒ DownloadReporter

Returns a new instance of DownloadReporter.



31
32
33
34
35
36
37
# File 'lib/shoes/cobbler.rb', line 31

def initialize(prog, status, size, initial_message,
               terminal_message = "complete")
  @prog = prog
  (@status = status).replace initial_message
  @total = size
  @count = 0.0
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



29
30
31
# File 'lib/shoes/cobbler.rb', line 29

def count
  @count
end

Instance Method Details

#doneObject



52
53
# File 'lib/shoes/cobbler.rb', line 52

def done
end

#fetch(filename, len) ⇒ Object



44
45
46
# File 'lib/shoes/cobbler.rb', line 44

def fetch(filename, len)
  @total = len
end

#update(len) ⇒ Object



48
49
50
# File 'lib/shoes/cobbler.rb', line 48

def update(len)
  @prog.fraction = len.to_f / @total.to_f
end

#updated(message) ⇒ Object



39
40
41
42
# File 'lib/shoes/cobbler.rb', line 39

def updated(message)
  @count += 1.0
  @prog.fraction = (@count / @total.to_f) * 0.5
end