Sha256: cb29b4c5435f1d8848638f9832183f95fef22ab6d9a2139252218fcefb64ffc2
Contents?: true
Size: 649 Bytes
Versions: 1
Compression:
Stored size: 649 Bytes
Contents
module Dl def self.download(url, raw = false) if !(url =~ /^https?:/i) parsed_url = "http://" + url end output "Downloading #{url}..." parsed_url = URI.parse(parsed_url) req = Net::HTTP::Get.new(parsed_url.path.empty? ? '/' : parsed_url.path) res = Net::HTTP.start(parsed_url.host, parsed_url.port) {|http| http.request(req) } output "#{url} downloaded to the file #{url.split("/").last}" if raw == true puts res.body else File.new(url.split("/").last, "w").write(res.body) end end private def self.output(string) puts string unless Dl::be_quiet == true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dl-1.2.4 | lib/dl/dl.rb |