image_monger_client 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/image_monger_client/client.rb +19 -17
- data/lib/image_monger_client/version.rb +1 -1
- metadata +1 -1
@@ -2,29 +2,31 @@ require 'net/http'
|
|
2
2
|
require 'json'
|
3
3
|
require 'cgi'
|
4
4
|
|
5
|
-
|
5
|
+
module ImageMongerClient
|
6
|
+
class ImageMongerClient::Client
|
6
7
|
|
7
|
-
|
8
|
+
attr_reader :pdf_url
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def initialize(pdf_url)
|
11
|
+
@pdf_url = pdf_url
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def pages_as_image_urls
|
15
|
+
JSON.parse(converter_response.body)
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
+
private
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def converter_response
|
21
|
+
Net::HTTP.get_response(URI(converter_url))
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def converter_url
|
25
|
+
"#{"http://imagemonger.lokalebasen.dk/pdf"}/#{encoded_pdf_url}/menu"
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
def encoded_pdf_url
|
29
|
+
CGI.escape(pdf_url)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|