Sha256: 7c4b28b345212528b9219ea1707f7cc8a373b62a86ccf71b0c0c073db6b0d1ba
Contents?: true
Size: 738 Bytes
Versions: 1
Compression:
Stored size: 738 Bytes
Contents
require 'faraday' module Eff class Downloader attr_reader :uri, :file, :response def initialize(url, file) self.uri = URI(url) self.file = file end def get @response = Faraday.get(uri) save end def success? response ? response.success? : false end def file=(value) clear_response! @file = File.expand_path(value, Dir.pwd) end def uri=(value) clear_response! @uri = URI(value) end private def save File.open(file, 'wb') do |f| f.write(response_body) end if success? success? end def response_body response.body end def clear_response! @response = nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eff-0.0.2 | lib/eff/downloader.rb |