Class: Bosh::Cli::DownloadWithProgress
- Defined in:
- lib/cli/download_with_progress.rb
Instance Method Summary collapse
-
#initialize(url, size) ⇒ DownloadWithProgress
constructor
A new instance of DownloadWithProgress.
- #perform ⇒ Object
- #sha1 ⇒ Object
- #sha1?(sha1) ⇒ Boolean
Constructor Details
#initialize(url, size) ⇒ DownloadWithProgress
Returns a new instance of DownloadWithProgress.
3 4 5 6 7 |
# File 'lib/cli/download_with_progress.rb', line 3 def initialize(url, size) @url = url @size = size @filename = File.basename(@url) end |
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cli/download_with_progress.rb', line 9 def perform = ProgressBar.new(@filename, @size) .file_transfer_mode download_in_chunks { |chunk| .inc(chunk.size) } .finish end |
#sha1 ⇒ Object
20 21 22 |
# File 'lib/cli/download_with_progress.rb', line 20 def sha1 Digest::SHA1.file(@filename).hexdigest end |
#sha1?(sha1) ⇒ Boolean
16 17 18 |
# File 'lib/cli/download_with_progress.rb', line 16 def sha1?(sha1) self.sha1 == sha1 end |