Class: Flickrcaptionr::Fetchers::Base
- Inherits:
-
Object
- Object
- Flickrcaptionr::Fetchers::Base
- Defined in:
- lib/flickrcaptionr/fetchers/base.rb
Overview
Base Fetcher, all others inherit from this. Don’t use it directly - it won’t do anything.
Instance Method Summary collapse
-
#can_handle_url?(url) ⇒ Boolean
Should return true if a given URL can be handled by this fetcher.
-
#download_file(url, out_path) ⇒ Object
Downloads a file to a given location using a simple HTTP GET.
-
#fetch(url) ⇒ Object
Resolve the exact file URL to download.
-
#initialize ⇒ Base
constructor
Setup the fetcher.
Constructor Details
#initialize ⇒ Base
Setup the fetcher
6 7 8 |
# File 'lib/flickrcaptionr/fetchers/base.rb', line 6 def initialize end |
Instance Method Details
#can_handle_url?(url) ⇒ Boolean
Should return true if a given URL can be handled by this fetcher.
19 20 21 |
# File 'lib/flickrcaptionr/fetchers/base.rb', line 19 def can_handle_url?(url) return false end |
#download_file(url, out_path) ⇒ Object
Downloads a file to a given location using a simple HTTP GET
13 14 15 16 17 |
# File 'lib/flickrcaptionr/fetchers/base.rb', line 13 def download_file(url, out_path) uri = URI(url) resp = Net::HTTP.get_response(uri) open(out_path, "wb"){|f| f.write(resp.body) } end |
#fetch(url) ⇒ Object
Resolve the exact file URL to download
10 11 |
# File 'lib/flickrcaptionr/fetchers/base.rb', line 10 def fetch(url) end |