class UrlFetcher

Public Class Methods

new(options = {}) click to toggle source
# File lib/fundamentus_data/util/url_fetcher.rb, line 5
def initialize(options = {})
  if options.has_key?(:verbose)
    @verbose = options[:verbose]
  end
end

Public Instance Methods

download(url) click to toggle source
# File lib/fundamentus_data/util/url_fetcher.rb, line 23
def download(url)
  open(url) do |f|
    f.read
  end
end
fetch(urls) click to toggle source
# File lib/fundamentus_data/util/url_fetcher.rb, line 11
def fetch(urls)
  responses = {}
  urls.each do |key, url|
    if @verbose
      puts "Downloading #{key} from #{url}"
    end
    responses[key] = download(url)
    sleep(0.5)
  end
  responses
end