class Toptranslation::Resource::Translation
Attributes
created_at[R]
external_checksum[R]
filename[R]
filesize[R]
identifier[R]
locale[R]
mime_type[R]
progress[R]
segments_sha1[R]
sha1[R]
updated_at[R]
Public Class Methods
new(connection, options = {})
click to toggle source
# File lib/toptranslation/resource/translation.rb, line 6 def initialize(connection, options = {}) @connection = connection @options = options update_from_response(options) end
Public Instance Methods
download()
click to toggle source
# File lib/toptranslation/resource/translation.rb, line 18 def download @connection.download(download_url, @filename) end
reference_documents()
click to toggle source
# File lib/toptranslation/resource/translation.rb, line 12 def reference_documents @reference_documents ||= @options['reference_documents'].inject([]) do |accu, reference_document| accu << ReferenceDocument.new(@connection, reference_document) end end
Private Instance Methods
download_url()
click to toggle source
# File lib/toptranslation/resource/translation.rb, line 24 def download_url @download_url ||= @connection.get("/translations/#{identifier}/download")['download_url'] end
update_from_response(response)
click to toggle source
# File lib/toptranslation/resource/translation.rb, line 28 def update_from_response(response) @identifier = response['identifier'] if response['identifier'] @filename = response['filename'] if response['filename'] @mime_type = response['mime_type'] if response['mime_type'] @progress = response['progress_in_percent'] if response['progress_in_percent'] @sha1 = response['sha1'] if response['sha1'] @segments_sha1 = response['segments_sha1'] if response['segments_sha1'] @external_checksum = response['external_checksum'] if response['external_checksum'] @updated_at = DateTime.parse(response['updated_at']) if response['updated_at'] @created_at = DateTime.parse(response['created_at']) if response['created_at'] @locale = Locale.new(response['locale']) if response['locale'] end