Class: DeepL::Resources::TranslationMemoryJobResult
- Inherits:
-
Object
- Object
- DeepL::Resources::TranslationMemoryJobResult
- Defined in:
- lib/deepl/resources/translation_memory_job.rb
Overview
The outcome of a translation memory import or export job.
Constant Summary collapse
- STATUS_AWAITING_INPUT =
'awaiting_input'- STATUS_PROCESSING =
'processing'- STATUS_COMPLETED =
'completed'- STATUS_DOWNLOADED =
'downloaded'- STATUS_FAILED =
'failed'- STATUS_EXPIRED =
'expired'
Instance Attribute Summary collapse
-
#download_url ⇒ Object
readonly
Returns the value of attribute download_url.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#required_action ⇒ Object
readonly
Returns the value of attribute required_action.
-
#skipped_segment_count ⇒ Object
readonly
Returns the value of attribute skipped_segment_count.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#translation_memory_id ⇒ Object
readonly
Returns the value of attribute translation_memory_id.
Instance Method Summary collapse
-
#awaiting_input? ⇒ true
Checks if the job is still waiting for the TMX file to be uploaded.
-
#error? ⇒ true
Checks if there was an error during the job, including it having expired.
-
#finished? ⇒ true
Checks if the job terminated.
-
#initialize(result) ⇒ TranslationMemoryJobResult
constructor
A new instance of TranslationMemoryJobResult.
- #to_s ⇒ Object
Constructor Details
#initialize(result) ⇒ TranslationMemoryJobResult
Returns a new instance of TranslationMemoryJobResult.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 22 def initialize(result) = result['status_metadata'] || {} error = result['error'] || {} @status = result['status'] @required_action = ['required_action'] @download_url = result['download_url'] @expires_at = Utils::TimeParser.parse_optional_time(result['expires_at']) @error_message = error['message'] @translation_memory_id = result['translation_memory_id'] @skipped_segment_count = result['skipped_segment_count'] end |
Instance Attribute Details
#download_url ⇒ Object (readonly)
Returns the value of attribute download_url.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def download_url @download_url end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def @error_message end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def expires_at @expires_at end |
#required_action ⇒ Object (readonly)
Returns the value of attribute required_action.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def required_action @required_action end |
#skipped_segment_count ⇒ Object (readonly)
Returns the value of attribute skipped_segment_count.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def skipped_segment_count @skipped_segment_count end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def status @status end |
#translation_memory_id ⇒ Object (readonly)
Returns the value of attribute translation_memory_id.
19 20 21 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 19 def translation_memory_id @translation_memory_id end |
Instance Method Details
#awaiting_input? ⇒ true
Checks if the job is still waiting for the TMX file to be uploaded. Note that the API detects an upload asynchronously, so a job keeps reporting this status for a while after its file has been uploaded.
52 53 54 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 52 def awaiting_input? status == STATUS_AWAITING_INPUT end |
#error? ⇒ true
Checks if there was an error during the job, including it having expired.
61 62 63 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 61 def error? [STATUS_FAILED, STATUS_EXPIRED].include?(status) end |
#finished? ⇒ true
Checks if the job terminated. Note that this could be due to an error as well, but means no further waiting is necessary.
41 42 43 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 41 def finished? [STATUS_COMPLETED, STATUS_DOWNLOADED, STATUS_FAILED, STATUS_EXPIRED].include?(status) end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/deepl/resources/translation_memory_job.rb', line 65 def to_s "TranslationMemoryJobResult: Status: #{status} - Error message: #{}" end |