Class: DeepL::Resources::DocumentHandle
- Defined in:
- lib/deepl/resources/document_handle.rb
Instance Attribute Summary collapse
-
#document_id ⇒ Object
readonly
Returns the value of attribute document_id.
-
#document_key ⇒ Object
readonly
Returns the value of attribute document_key.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(document_id, document_key, *args) ⇒ DocumentHandle
constructor
A new instance of DocumentHandle.
- #to_s ⇒ Object
-
#wait_until_document_translation_finished ⇒ DeepL::Resources::DocumentTranslationStatus
For this DocumentHandle, waits until the document translation is finished and returns the final status of the document.
Constructor Details
#initialize(document_id, document_key, *args) ⇒ DocumentHandle
Returns a new instance of DocumentHandle.
11 12 13 14 15 16 |
# File 'lib/deepl/resources/document_handle.rb', line 11 def initialize(document_id, document_key, *args) super(*args) @document_id = document_id @document_key = document_key end |
Instance Attribute Details
#document_id ⇒ Object (readonly)
Returns the value of attribute document_id.
9 10 11 |
# File 'lib/deepl/resources/document_handle.rb', line 9 def document_id @document_id end |
#document_key ⇒ Object (readonly)
Returns the value of attribute document_key.
9 10 11 |
# File 'lib/deepl/resources/document_handle.rb', line 9 def document_key @document_key end |
Instance Method Details
#to_s ⇒ Object
18 19 20 |
# File 'lib/deepl/resources/document_handle.rb', line 18 def to_s "DocumentHandle: ID: #{document_id} - Key: #{document_key}" end |
#wait_until_document_translation_finished ⇒ DeepL::Resources::DocumentTranslationStatus
For this DocumentHandle, waits until the document translation is finished and returns the final status of the document.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/deepl/resources/document_handle.rb', line 29 def wait_until_document_translation_finished doc_status = nil max_tries = max_doc_status_queries num_tries = 0 loop do num_tries += 1 sleep(calculate_waiting_time(doc_status)) unless doc_status.nil? doc_status = DeepL.document.get_status(self) break if doc_status.finished? || num_tries > max_tries end doc_status end |