Class: DocumentCloud::Document
- Inherits:
-
Object
- Object
- DocumentCloud::Document
- Defined in:
- lib/document_cloud/document.rb
Instance Attribute Summary collapse
-
#access ⇒ Object
readonly
Returns the value of attribute access.
-
#canonical_url ⇒ Object
readonly
Returns the value of attribute canonical_url.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#display_language ⇒ Object
readonly
Returns the value of attribute display_language.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #image(page, size = 1) ⇒ Object
-
#initialize(attrs = {}) ⇒ Document
constructor
A new instance of Document.
- #pdf ⇒ Object
- #print_annotations ⇒ Object
- #related_article ⇒ Object
- #text ⇒ Object
- #thumbnail ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Document
Returns a new instance of Document.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/document_cloud/document.rb', line 6 def initialize(attrs={}) @id = attrs[:id] @title = attrs[:title] @access = attrs[:access] @pages = attrs[:pages] @description = attrs[:description] @source = attrs[:source] @canonical_url = attrs[:canonical_url] @language = attrs[:language] @display_language = attrs[:display_language] @created_at = DateTime.parse(attrs[:created_at]) @updated_at = DateTime.parse(attrs[:updated_at]) @resources = attrs[:resources] end |
Instance Attribute Details
#access ⇒ Object (readonly)
Returns the value of attribute access.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def access @access end |
#canonical_url ⇒ Object (readonly)
Returns the value of attribute canonical_url.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def canonical_url @canonical_url end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def description @description end |
#display_language ⇒ Object (readonly)
Returns the value of attribute display_language.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def display_language @display_language end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def id @id end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def language @language end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def pages @pages end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def source @source end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def title @title end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def updated_at @updated_at end |
Instance Method Details
#image(page, size = 1) ⇒ Object
41 42 43 |
# File 'lib/document_cloud/document.rb', line 41 def image(page, size=1) @resources[:page][:image].gsub(/\{page\}/, page.to_s).gsub(/\{size\}/,size.to_s) end |
#pdf ⇒ Object
21 22 23 |
# File 'lib/document_cloud/document.rb', line 21 def pdf @resources[:pdf] end |
#print_annotations ⇒ Object
25 26 27 |
# File 'lib/document_cloud/document.rb', line 25 def print_annotations @resources[:print_annotations] end |
#related_article ⇒ Object
29 30 31 |
# File 'lib/document_cloud/document.rb', line 29 def @resources[:related_article] end |
#text ⇒ Object
33 34 35 |
# File 'lib/document_cloud/document.rb', line 33 def text @resources[:text] end |
#thumbnail ⇒ Object
37 38 39 |
# File 'lib/document_cloud/document.rb', line 37 def thumbnail @resources[:thumbnail] end |