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.
-
#mentions ⇒ Object
readonly
Returns the value of attribute mentions.
-
#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
- #entities ⇒ Object
- #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 20 |
# 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] @mentions = attrs[:mentions] 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 |
#mentions ⇒ Object (readonly)
Returns the value of attribute mentions.
3 4 5 |
# File 'lib/document_cloud/document.rb', line 3 def mentions @mentions 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
#entities ⇒ Object
46 47 48 49 |
# File 'lib/document_cloud/document.rb', line 46 def entities @entities ||= DocumentCloud.entities(@id) @entities end |
#image(page, size = 1) ⇒ Object
42 43 44 |
# File 'lib/document_cloud/document.rb', line 42 def image(page, size=1) @resources[:page][:image].gsub(/\{page\}/, page.to_s).gsub(/\{size\}/,size.to_s) end |
#pdf ⇒ Object
22 23 24 |
# File 'lib/document_cloud/document.rb', line 22 def pdf @resources[:pdf] end |
#print_annotations ⇒ Object
26 27 28 |
# File 'lib/document_cloud/document.rb', line 26 def print_annotations @resources[:print_annotations] end |
#related_article ⇒ Object
30 31 32 |
# File 'lib/document_cloud/document.rb', line 30 def @resources[:related_article] end |
#text ⇒ Object
34 35 36 |
# File 'lib/document_cloud/document.rb', line 34 def text @resources[:text] end |
#thumbnail ⇒ Object
38 39 40 |
# File 'lib/document_cloud/document.rb', line 38 def thumbnail @resources[:thumbnail] end |