Class: Chromedriver::Binary::DownloadProgress
- Inherits:
-
Object
- Object
- Chromedriver::Binary::DownloadProgress
- Defined in:
- lib/chromedriver/binary/download_progress.rb
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(logger:, step_bytes: 1 * 1024 * 1024) ⇒ DownloadProgress
constructor
A new instance of DownloadProgress.
- #track(chunk_size) ⇒ Object
Constructor Details
#initialize(logger:, step_bytes: 1 * 1024 * 1024) ⇒ DownloadProgress
6 7 8 9 10 11 12 |
# File 'lib/chromedriver/binary/download_progress.rb', line 6 def initialize(logger:, step_bytes: 1 * 1024 * 1024) # Default: 1 MB @logger = logger @step_bytes = step_bytes @total_bytes = 0 @next_log_at = step_bytes end |
Instance Method Details
#finish ⇒ Object
24 25 26 27 |
# File 'lib/chromedriver/binary/download_progress.rb', line 24 def finish mb = (@total_bytes.to_f / (1024 * 1024)).round(2) @logger.info("Download complete! ✅ Total: #{mb} MB") end |
#track(chunk_size) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/chromedriver/binary/download_progress.rb', line 14 def track(chunk_size) @total_bytes += chunk_size return unless @total_bytes >= @next_log_at mb = (@total_bytes.to_f / (1024 * 1024)).round(2) @logger.debug("Downloaded ~#{mb} MB 📦") @next_log_at += @step_bytes end |