Class: DeepL::Requests::TranslateText

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/requests/translate_text.rb

Constant Summary

Constants inherited from Base

Base::API_VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#api, #response

Instance Method Summary collapse

Constructor Details

#initialize(api, text, source_lang, target_lang) ⇒ TranslateText

Returns a new instance of TranslateText.



6
7
8
9
10
11
# File 'lib/deepl/requests/translate_text.rb', line 6

def initialize(api, text, source_lang, target_lang)
  super(api)
  @text = text
  @source_lang = source_lang
  @target_lang = target_lang
end

Instance Attribute Details

#source_langObject (readonly)

Returns the value of attribute source_lang.



4
5
6
# File 'lib/deepl/requests/translate_text.rb', line 4

def source_lang
  @source_lang
end

#target_langObject (readonly)

Returns the value of attribute target_lang.



4
5
6
# File 'lib/deepl/requests/translate_text.rb', line 4

def target_lang
  @target_lang
end

#textObject (readonly)

Returns the value of attribute text.



4
5
6
# File 'lib/deepl/requests/translate_text.rb', line 4

def text
  @text
end

Instance Method Details

#requestObject



13
14
15
16
# File 'lib/deepl/requests/translate_text.rb', line 13

def request
  payload = { text: text, source_lang: source_lang, target_lang: target_lang }
  build_texts(*post(payload))
end