Module: PageGlimpse
- Defined in:
- lib/page_glimpse.rb,
lib/page_glimpse/api.rb,
lib/page_glimpse/image.rb,
lib/page_glimpse/exceptions.rb,
lib/page_glimpse/json_parser.rb,
lib/page_glimpse/image_parser.rb
Defined Under Namespace
Classes: API, Exception, Image, ImageParser, InvalidDeveloperKeyError, JsonParser
Class Method Summary collapse
-
.developer_key=(key) ⇒ Object
Sets the developer key to use with the requests.
-
.exist?(url, options = {}) ⇒ Boolean
Returns
true
if the thumbnail exists on Page Glimpse,false
otherwise. -
.get(url, options = {}) ⇒ Object
Returns the binary data for the thumbnail requested.
-
.queue(url) ⇒ Object
Instructs Page Glimpse to enqueue the thumbnailing of a specific URL.
Class Method Details
.developer_key=(key) ⇒ Object
Sets the developer key to use with the requests.
14 15 16 |
# File 'lib/page_glimpse.rb', line 14 def self.developer_key=(key) @@developer_key = key end |
.exist?(url, options = {}) ⇒ Boolean
Returns true
if the thumbnail exists on Page Glimpse, false
otherwise.
21 22 23 24 25 26 27 28 29 |
# File 'lib/page_glimpse.rb', line 21 def self.exist?(url, = {}) [:url] = CGI.escape(url) response = api.exist?() response.kind_of?(Array) && response.size == 2 && response[1] == API::THUMBNAIL_EXISTS rescue RestClient::ResourceNotFound return false rescue RestClient::RequestFailed handle_failure($!) end |
.get(url, options = {}) ⇒ Object
Returns the binary data for the thumbnail requested.
Valid options:
- size
-
Sets the size of the graphic to get from Page Glimpse.
Available options are:
- “
small
” -
150x108 px
- “
medium
” -
280x202 px
- “
large
” -
430x310 px
- “
- nothumb
-
Indicates if the thumbnails for the domain root should be displayed. If set to “
no
”, it will display the not found image, otherwise it will display the thumbnails for root domain page. Default value is “yes
”. - root
-
Indicates if the thumbnails for the domain root should be displayed. If set to “
no
”, it will display the not found image, otherwise it will display the thumbnails for root domain page. Default value is “yes
”.
55 56 57 58 59 60 |
# File 'lib/page_glimpse.rb', line 55 def self.get(url, = {}) [:url] = CGI.escape(url) api.thumbnail() rescue RestClient::RequestFailed handle_failure($!) end |
.queue(url) ⇒ Object
Instructs Page Glimpse to enqueue the thumbnailing of a specific URL.
65 66 67 68 69 70 |
# File 'lib/page_glimpse.rb', line 65 def self.queue(url) response = api.queue(:url => CGI.escape(url)) response.kind_of?(Array) && response.size == 2 && response[1] == API::QUEUE_SUCCESS rescue RestClient::RequestFailed handle_failure($!) end |