Class: Crocodoc::Download
- Inherits:
-
Object
- Object
- Crocodoc::Download
- Defined in:
- lib/crocodoc/download.rb
Overview
Provides access to the Crocodoc Download API. The Download API is used for downloading an original of a document, a PDF of a document, a thumbnail of a document, and text extracted from a document.
Constant Summary collapse
- @@path =
The Download API path relative to the base API path
'/download/'
Class Method Summary collapse
-
.document(uuid, is_pdf = false, is_annotated = false, filter = nil) ⇒ String
Download a document’s original file from Crocodoc.
-
.path ⇒ Object
Get the path.
-
.path=(path) ⇒ Object
Set the path.
-
.text(uuid) ⇒ String
Download a document’s extracted text from Crocodoc.
-
.thumbnail(uuid, width = nil, height = nil) ⇒ String
Download a document’s thumbnail from Crocodoc with an optional size.
Class Method Details
.document(uuid, is_pdf = false, is_annotated = false, filter = nil) ⇒ String
Download a document’s original file from Crocodoc. The file can optionally be downloaded as a PDF, as another filename, with annotations, and with filtered annotations.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/crocodoc/download.rb', line 32 def self.document(uuid, is_pdf=false, is_annotated=false, filter=nil) get_params = {uuid: uuid} get_params['pdf'] = 'true' if is_pdf get_params['annotated'] = 'true' if is_annotated if filter filter = filter.join(',') if filter.is_a? Array get_params['filter'] = filter end Crocodoc._request(self.path, 'document', get_params, nil, false) end |
.path ⇒ Object
Get the path
15 16 17 |
# File 'lib/crocodoc/download.rb', line 15 def self.path @@path end |
.path=(path) ⇒ Object
Set the path
10 11 12 |
# File 'lib/crocodoc/download.rb', line 10 def self.path=(path) @@path = path end |
.text(uuid) ⇒ String
Download a document’s extracted text from Crocodoc.
51 52 53 54 |
# File 'lib/crocodoc/download.rb', line 51 def self.text(uuid) get_params = {uuid: uuid} Crocodoc._request(self.path, 'text', get_params, nil, false) end |
.thumbnail(uuid, width = nil, height = nil) ⇒ String
Download a document’s thumbnail from Crocodoc with an optional size.
64 65 66 67 68 69 70 71 72 |
# File 'lib/crocodoc/download.rb', line 64 def self.thumbnail(uuid, width=nil, height=nil) get_params = {uuid: uuid} if width != nil and height != nil get_params['size'] = String(width) + 'x' + String(height) end Crocodoc._request(self.path, 'thumbnail', get_params, nil, false) end |