Skip to content

Instantly share code, notes, and snippets.

@ksss
Last active June 22, 2016 09:25
Show Gist options
  • Save ksss/1123c4981774e530a8f577cb10ec1e9f to your computer and use it in GitHub Desktop.
Save ksss/1123c4981774e530a8f577cb10ec1e9f to your computer and use it in GitHub Desktop.
require 'open-uri'
class MultiDownload
def initialize(*urls)
@urls = urls
end
def to_h
@urls.map { |url|
Thread.new(url) do |url|
content = open(url, &:read) rescue nil
[url, content]
end
}.map(&:value).to_h
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment