lib/eff/downloader.rb in eff-0.0.1 vs lib/eff/downloader.rb in eff-0.0.2

- old
+ new

@@ -9,22 +9,15 @@ self.file = file end def get @response = Faraday.get(uri) + save end - def save - File.open(file, 'wb') do |f| - f.write(response_body) - end if success? - end - - # TODO: should this really trigger it to download? def success? - get unless response - @response.success? + response ? response.success? : false end def file=(value) clear_response! @file = File.expand_path(value, Dir.pwd) @@ -34,9 +27,16 @@ 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!