Class | Gem::StreamUI::VerboseDownloadReporter |
In: |
lib/rubygems/user_interaction.rb
|
Parent: | Object |
A progress reporter that prints out messages about the current progress.
file_name | [R] | |
progress | [R] | |
total_bytes | [R] |
# File lib/rubygems/user_interaction.rb, line 468 468: def initialize(out_stream, *args) 469: @out = out_stream 470: @progress = 0 471: end
# File lib/rubygems/user_interaction.rb, line 494 494: def done 495: @progress = 100 if @units == '%' 496: update_display(true, true) 497: end
# File lib/rubygems/user_interaction.rb, line 473 473: def fetch(file_name, total_bytes) 474: @file_name = file_name 475: @total_bytes = total_bytes.to_i 476: @units = @total_bytes.zero? ? 'B' : '%' 477: 478: update_display(false) 479: end
# File lib/rubygems/user_interaction.rb, line 481 481: def update(bytes) 482: new_progress = if @units == 'B' then 483: bytes 484: else 485: ((bytes.to_f * 100) / total_bytes.to_f).ceil 486: end 487: 488: return if new_progress == @progress 489: 490: @progress = new_progress 491: update_display 492: end