Class: Toptranslation::Resource::Upload

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Upload.



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

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

Instance Attribute Details

#document_store_idObject (readonly)

Returns the value of attribute document_store_id.



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

def document_store_id
  @document_store_id
end

#document_tokenObject (readonly)

Returns the value of attribute document_token.



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

def document_token
  @document_token
end

#sha1Object (readonly)

Returns the value of attribute sha1.



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

def sha1
  @sha1
end

Instance Method Details

#upload(filepath, type = 'document', &block) ⇒ Object



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

def upload(filepath, type = 'document', &block)
  puts "# Uploading: #{filepath}" if @connection.verbose
  response = @connection.upload(filepath, type, &block)

  @document_store_id = response['identifier']
  @document_token    = response['document_token']
  @sha1              = response['sha1']

  self
end