Class: Screencap::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/screencap/fetcher.rb

Instance Method Summary collapse

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_filenameObject



25
26
27
# File 'lib/screencap/fetcher.rb', line 25

def clean_filename
  "#{TMP_DIRECTORY}/#{@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[:div])
  fetched_file
end

#fetched_fileObject



17
18
19
# File 'lib/screencap/fetcher.rb', line 17

def fetched_file
  File.open(filename)
end

#filenameObject



13
14
15
# File 'lib/screencap/fetcher.rb', line 13

def filename
  @filename
end

#raster(*args) ⇒ Object



21
22
23
# File 'lib/screencap/fetcher.rb', line 21

def raster(*args)
  Screencap::Phantom.rasterize(*args)
end