grimen-page_glimpse 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/page_glimse.rb +10 -5
- metadata +1 -1
data/lib/page_glimse.rb
CHANGED
@@ -40,8 +40,8 @@ class PageGlimse
|
|
40
40
|
@devkey = devkey
|
41
41
|
end
|
42
42
|
|
43
|
-
# Get
|
44
|
-
def
|
43
|
+
# Get thumbnail URL for linking.
|
44
|
+
def thumbnail_url(url, options = {})
|
45
45
|
options = defaults.merge(options)
|
46
46
|
@url = url
|
47
47
|
@size = valid_size_value(options[:size])
|
@@ -49,13 +49,17 @@ class PageGlimse
|
|
49
49
|
@nothumb = options[:nothumb]
|
50
50
|
|
51
51
|
query_url = generate_url('thumbnails')
|
52
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get single thumbnail image (PNG).
|
55
|
+
def thumbnail(url, options = {})
|
56
|
+
response = self.class.get(thumbnail_url)
|
53
57
|
handle_response(response)
|
54
58
|
response.body
|
55
59
|
end
|
56
60
|
alias :thumbnails :thumbnail
|
57
61
|
|
58
|
-
# Export single thumbnail into a file.
|
62
|
+
# Export single thumbnail into a image file (PNG).
|
59
63
|
def save!(url, path, options = {})
|
60
64
|
begin
|
61
65
|
data = thumbnail(url, options)
|
@@ -125,7 +129,8 @@ class PageGlimse
|
|
125
129
|
params << "root=#{@root}" if ACTION_PARAMS[action].include?(:thumbnail)
|
126
130
|
params << "nothumb=#{@nothumb}" if ACTION_PARAMS[action].include?(:nothumb) && @nothumb && !@nothumb.empty?
|
127
131
|
params << "devkey=#{@devkey}" if ACTION_PARAMS[action].include?(:devkey)
|
128
|
-
"/#{action}?#{params.join('&')}"
|
132
|
+
query_url = "/#{action}?#{params.join('&')}"
|
133
|
+
@thumbnail_url =
|
129
134
|
end
|
130
135
|
|
131
136
|
end
|