Class: Kraps::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/kraps/downloader.rb

Class Method Summary collapse

Class Method Details

.download_all(prefix:, concurrency:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kraps/downloader.rb', line 3

def self.download_all(prefix:, concurrency:)
  temp_paths = TempPaths.new

  files = Kraps.driver.list(prefix: prefix).sort

  temp_paths_index = files.each_with_object({}) do |file, hash|
    hash[file] = temp_paths.add
  end

  Parallelizer.each(files, concurrency) do |file|
    Kraps.driver.download(file, temp_paths_index[file].path)
  end

  temp_paths
end