Class: Eff::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/eff/downloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, file) ⇒ Downloader

Returns a new instance of Downloader.



7
8
9
10
# File 'lib/eff/downloader.rb', line 7

def initialize(url, file)
  self.uri  = URI(url)
  self.file = file
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/eff/downloader.rb', line 5

def file
  @file
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/eff/downloader.rb', line 5

def response
  @response
end

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/eff/downloader.rb', line 5

def uri
  @uri
end

Instance Method Details

#getObject



12
13
14
15
# File 'lib/eff/downloader.rb', line 12

def get
  @response = Faraday.get(uri)
  save
end

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/eff/downloader.rb', line 17

def success?
  response ? response.success? : false
end