Class: DeepL::Resources::TranslationMemoryJob

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/resources/translation_memory_job.rb

Overview

Status of a translation memory import or export job. The API returns exactly one result.

Constant Summary collapse

OPERATION_IMPORT =
'import'
OPERATION_EXPORT =
'export'

Instance Attribute Summary collapse

Attributes inherited from Base

#request, #response

Instance Method Summary collapse

Constructor Details

#initialize(job, *args) ⇒ TranslationMemoryJob

Returns a new instance of TranslationMemoryJob.



81
82
83
84
85
86
# File 'lib/deepl/resources/translation_memory_job.rb', line 81

def initialize(job, *args)
  super(*args)
  extract_basic_fields(job)
  extract_parameters(job)
  @results = (job['results'] || []).map { |result| TranslationMemoryJobResult.new(result) }
end

Instance Attribute Details

#creation_timeObject (readonly)

Returns the value of attribute creation_time.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def creation_time
  @creation_time
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def display_name
  @display_name
end

#job_idObject (readonly)

Returns the value of attribute job_id.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def job_id
  @job_id
end

#operationObject (readonly)

Returns the value of attribute operation.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def operation
  @operation
end

#productObject (readonly)

Returns the value of attribute product.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def product
  @product
end

#resultsObject (readonly)

Returns the value of attribute results.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def results
  @results
end

#source_content_lengthObject (readonly)

Returns the value of attribute source_content_length.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def source_content_length
  @source_content_length
end

#source_content_typeObject (readonly)

Returns the value of attribute source_content_type.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def source_content_type
  @source_content_type
end

#translation_memory_idObject (readonly)

Returns the value of attribute translation_memory_id.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def translation_memory_id
  @translation_memory_id
end

#updated_timeObject (readonly)

Returns the value of attribute updated_time.



77
78
79
# File 'lib/deepl/resources/translation_memory_job.rb', line 77

def updated_time
  @updated_time
end

Instance Method Details

#awaiting_input?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/deepl/resources/translation_memory_job.rb', line 105

def awaiting_input?
  result ? result.awaiting_input? : false
end

#error?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/deepl/resources/translation_memory_job.rb', line 109

def error?
  result ? result.error? : false
end

#error_messageObject



113
114
115
# File 'lib/deepl/resources/translation_memory_job.rb', line 113

def error_message
  result&.error_message
end

#finished?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/deepl/resources/translation_memory_job.rb', line 101

def finished?
  result ? result.finished? : false
end

#resultDeepL::Resources::TranslationMemoryJobResult?

The single result of the job, or nil if the API returned none.



93
94
95
# File 'lib/deepl/resources/translation_memory_job.rb', line 93

def result
  results.first
end

#statusObject



97
98
99
# File 'lib/deepl/resources/translation_memory_job.rb', line 97

def status
  result&.status
end

#to_sObject



117
118
119
# File 'lib/deepl/resources/translation_memory_job.rb', line 117

def to_s
  "TranslationMemoryJob: #{operation} - ID: #{job_id} - Status: #{status}"
end