Class: Screencap::Fetcher
- Inherits:
-
Object
- Object
- Screencap::Fetcher
- Defined in:
- lib/screencap/fetcher.rb
Instance Method Summary collapse
- #clean_filename ⇒ Object
- #fetch(opts = {}) ⇒ Object
- #fetched_file ⇒ Object
- #filename ⇒ Object
-
#initialize(url) ⇒ Fetcher
constructor
A new instance of Fetcher.
- #raster(*args) ⇒ Object
Constructor Details
#initialize(url) ⇒ Fetcher
Returns a new instance of Fetcher.
3 4 5 |
# File 'lib/screencap/fetcher.rb', line 3 def initialize(url) @url = url end |
Instance Method Details
#clean_filename ⇒ Object
27 28 29 |
# File 'lib/screencap/fetcher.rb', line 27 def clean_filename "#{@url.delete('/.:?!')}.png" end |
#fetch(opts = {}) ⇒ Object
7 8 9 10 11 |
# File 'lib/screencap/fetcher.rb', line 7 def fetch(opts = {}) @filename = opts.fetch(:output, clean_filename) raster(@url, @filename, opts) fetched_file end |
#fetched_file ⇒ Object
17 18 19 20 21 |
# File 'lib/screencap/fetcher.rb', line 17 def fetched_file if File.exists?(filename) File.open(filename) end end |
#filename ⇒ Object
13 14 15 |
# File 'lib/screencap/fetcher.rb', line 13 def filename @filename end |