module Dl def self.download(url, raw = false) session = Patron::Session.new output "Downloading #{url}..." response = session.get url if raw == true puts response.body else if Dl::file != nil filename = Dl::file else filename = response.url.split('/').pop end output "Downloaded to file #{filename}!" File.new(filename, 'w').write(response.body) end end private def self.output(string) puts string unless Dl::be_quiet == true end end