Class: DeepL::Resources::DocumentTranslationStatus

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

Instance Attribute Summary collapse

Attributes inherited from Base

#request, #response

Instance Method Summary collapse

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_charactersObject (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_idObject (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_messageObject (readonly)

Returns the value of attribute error_message.



9
10
11
# File 'lib/deepl/resources/document_translation_status.rb', line 9

def error_message
  @error_message
end

#seconds_remainingObject (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

#statusObject (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

Returns:

  • (true)

    if so



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.

Returns:

  • (true)

    if so



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

Returns:

  • (true)

    if so



31
32
33
# File 'lib/deepl/resources/document_translation_status.rb', line 31

def successful?
  status == 'done'
end

#to_sObject



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: #{error_message}"
end