Sha256: 8528624c511a38bc8f3e98849722638be3398e9f8f10d0567ce340d1b78e7a5b
Contents?: true
Size: 690 Bytes
Versions: 5
Compression:
Stored size: 690 Bytes
Contents
=begin rdoc = DOWNLOAD.RB *Author*:: Tamara Temple <tamara@tamaratemple.com> *Since*:: 2013-05-27 *Copyright*:: (c) 2013 Tamara Temple Web Development *License*:: MIT =end require 'mechanize' module Scrapers module Download def self.download(url,dir=".") Scrapers.agent.pluggable_parser.default = Mechanize::Download @dir = validate_directory(dir) dl = Scrapers.agent.get(url) Dir.chdir(@dir) do |dir| dl.save() end File.join(@dir,dl.filename) end def self.validate_directory(d) raise "#{d} is not a writable directory!" unless File.directory?(d) and File.writable?(d) d end end end
Version data entries
5 entries across 5 versions & 1 rubygems