Class: Eff::Downloader
- Inherits:
-
Object
- Object
- Eff::Downloader
- Defined in:
- lib/eff/downloader.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(url, file) ⇒ Downloader
constructor
A new instance of Downloader.
- #success? ⇒ Boolean
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
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/eff/downloader.rb', line 5 def file @file end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/eff/downloader.rb', line 5 def response @response end |
#uri ⇒ Object
Returns the value of attribute uri.
5 6 7 |
# File 'lib/eff/downloader.rb', line 5 def uri @uri end |
Instance Method Details
#get ⇒ Object
12 13 14 15 |
# File 'lib/eff/downloader.rb', line 12 def get @response = Faraday.get(uri) save end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/eff/downloader.rb', line 17 def success? response ? response.success? : false end |