Class: Falkor::Download

Inherits:
Object
  • Object
show all
Includes:
TrackableProgress
Defined in:
lib/falkor/download.rb

Instance Method Summary collapse

Methods included from TrackableProgress

#report_progress

Constructor Details

#initialize(url, file_name) ⇒ Download



9
10
11
12
# File 'lib/falkor/download.rb', line 9

def initialize(url, file_name)
  @url = url
  @file_name = file_name
end

Instance Method Details

#downloadObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/falkor/download.rb', line 14

def download
  return destination if File.exist?(destination)

  request do |response, file_size|
    next unless success?(response)

    report_progress(:write_chunks, file_size, response, &Proc.new)
    destination
  end
end