Class: Toptranslation::Resource::ReferenceDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/toptranslation/resource/reference_document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, options = {}) ⇒ ReferenceDocument

Returns a new instance of ReferenceDocument.



5
6
7
8
9
# File 'lib/toptranslation/resource/reference_document.rb', line 5

def initialize(connection, options = {})
  @connection = connection
  @options = options
  update_from_response(options)
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



3
4
5
# File 'lib/toptranslation/resource/reference_document.rb', line 3

def comment
  @comment
end

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/toptranslation/resource/reference_document.rb', line 3

def created_at
  @created_at
end

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/toptranslation/resource/reference_document.rb', line 3

def filename
  @filename
end

#filesizeObject (readonly)

Returns the value of attribute filesize.



3
4
5
# File 'lib/toptranslation/resource/reference_document.rb', line 3

def filesize
  @filesize
end

#identifierObject (readonly)

Returns the value of attribute identifier.



3
4
5
# File 'lib/toptranslation/resource/reference_document.rb', line 3

def identifier
  @identifier
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



3
4
5
# File 'lib/toptranslation/resource/reference_document.rb', line 3

def mime_type
  @mime_type
end

Instance Method Details

#download(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/toptranslation/resource/reference_document.rb', line 11

def download(options = {})
  download_path = if options[:path]
                    options[:path]
                  else
                    tempfile = Tempfile.new
                    temp_path = tempfile.path
                    tempfile.close
                    temp_path
                  end
  @connection.download(download_url, download_path)
end

#download_urlObject



23
24
25
# File 'lib/toptranslation/resource/reference_document.rb', line 23

def download_url
  @download_url ||= @connection.get("/reference_documents/#{identifier}/download", version: 2)['download_url']
end