Parent

Class Index [+]

Quicksearch

Gem::StreamUI::VerboseDownloadReporter

A progress reporter that prints out messages about the current progress.

Attributes

file_name[R]
total_bytes[R]
progress[R]

Public Class Methods

new(out_stream, *args) click to toggle source
     # File lib/rubygems/user_interaction.rb, line 480
480:     def initialize(out_stream, *args)
481:       @out = out_stream
482:       @progress = 0
483:     end

Public Instance Methods

done() click to toggle source
     # File lib/rubygems/user_interaction.rb, line 506
506:     def done
507:       @progress = 100 if @units == '%'
508:       update_display(true, true)
509:     end
fetch(file_name, total_bytes) click to toggle source
     # File lib/rubygems/user_interaction.rb, line 485
485:     def fetch(file_name, total_bytes)
486:       @file_name = file_name
487:       @total_bytes = total_bytes.to_i
488:       @units = @total_bytes.zero? ? 'B' : '%'
489: 
490:       update_display(false)
491:     end
update(bytes) click to toggle source
     # File lib/rubygems/user_interaction.rb, line 493
493:     def update(bytes)
494:       new_progress = if @units == 'B' then
495:                        bytes
496:                      else
497:                        ((bytes.to_f * 100) / total_bytes.to_f).ceil
498:                      end
499: 
500:       return if new_progress == @progress
501: 
502:       @progress = new_progress
503:       update_display
504:     end

Private Instance Methods

update_display(show_progress = true, new_line = false) click to toggle source
     # File lib/rubygems/user_interaction.rb, line 513
513:     def update_display(show_progress = true, new_line = false)
514:       return unless @out.tty?
515: 
516:       if show_progress then
517:         @out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
518:       else
519:         @out.print "Fetching: %s" % @file_name
520:       end
521:       @out.puts if new_line
522:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.