Class: DocumentCloud::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/document_cloud/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#accessObject (readonly)

Returns the value of attribute access.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def access
  @access
end

#canonical_urlObject (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_atObject (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

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def description
  @description
end

#display_languageObject (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

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def id
  @id
end

#languageObject (readonly)

Returns the value of attribute language.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def language
  @language
end

#pagesObject (readonly)

Returns the value of attribute pages.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def pages
  @pages
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def source
  @source
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/document_cloud/document.rb', line 3

def title
  @title
end

#updated_atObject (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

#pdfObject



21
22
23
# File 'lib/document_cloud/document.rb', line 21

def pdf
  @resources[:pdf]
end


25
26
27
# File 'lib/document_cloud/document.rb', line 25

def print_annotations
  @resources[:print_annotations]
end

#related_articleObject



29
30
31
# File 'lib/document_cloud/document.rb', line 29

def related_article
  @resources[:related_article]
end

#textObject



33
34
35
# File 'lib/document_cloud/document.rb', line 33

def text
  @resources[:text]
end

#thumbnailObject



37
38
39
# File 'lib/document_cloud/document.rb', line 37

def thumbnail
  @resources[:thumbnail]
end