Class: DeepL::Resources::DocumentTranslationStatus
- Defined in:
- lib/deepl/resources/document_translation_status.rb
Instance Attribute Summary collapse
-
#billed_characters ⇒ Object
readonly
Returns the value of attribute billed_characters.
-
#document_id ⇒ Object
readonly
Returns the value of attribute document_id.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#seconds_remaining ⇒ Object
readonly
Returns the value of attribute seconds_remaining.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Attributes inherited from Base
Instance Method Summary collapse
-
#error? ⇒ true
Checks if there was an error during translation.
-
#finished? ⇒ true
Checks if the translation process terminated.
-
#initialize(response, *args) ⇒ DocumentTranslationStatus
constructor
A new instance of DocumentTranslationStatus.
-
#successful? ⇒ true
Checks if the translation finished successfully.
- #to_s ⇒ Object
Constructor Details
#initialize(response, *args) ⇒ DocumentTranslationStatus
Returns a new instance of DocumentTranslationStatus.
11 12 13 14 15 16 17 18 19 |
# File 'lib/deepl/resources/document_translation_status.rb', line 11 def initialize(response, *args) super(*args) @document_id = response['document_id'] @status = response['status'] @seconds_remaining = response['seconds_remaining'] @billed_characters = response['billed_characters'] @error_message = response['error_message'] end |
Instance Attribute Details
#billed_characters ⇒ Object (readonly)
Returns the value of attribute billed_characters.
9 10 11 |
# File 'lib/deepl/resources/document_translation_status.rb', line 9 def billed_characters @billed_characters end |
#document_id ⇒ Object (readonly)
Returns the value of attribute document_id.
9 10 11 |
# File 'lib/deepl/resources/document_translation_status.rb', line 9 def document_id @document_id end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
9 10 11 |
# File 'lib/deepl/resources/document_translation_status.rb', line 9 def @error_message end |
#seconds_remaining ⇒ Object (readonly)
Returns the value of attribute seconds_remaining.
9 10 11 |
# File 'lib/deepl/resources/document_translation_status.rb', line 9 def seconds_remaining @seconds_remaining end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/deepl/resources/document_translation_status.rb', line 9 def status @status end |
Instance Method Details
#error? ⇒ true
Checks if there was an error during translation
40 41 42 |
# File 'lib/deepl/resources/document_translation_status.rb', line 40 def error? status == 'error' end |
#finished? ⇒ true
Checks if the translation process terminated. Note that this could be due to an error as well, but means no further waiting is necessary.
49 50 51 |
# File 'lib/deepl/resources/document_translation_status.rb', line 49 def finished? successful? || error? end |
#successful? ⇒ true
Checks if the translation finished successfully
31 32 33 |
# File 'lib/deepl/resources/document_translation_status.rb', line 31 def successful? status == 'done' end |
#to_s ⇒ Object
21 22 23 24 |
# File 'lib/deepl/resources/document_translation_status.rb', line 21 def to_s "DocumentTranslationStatus: ID: #{document_id} - Status: #{status} " \ "- Error message: #{}" end |