Class: DeepL::Requests::Translate
- Defined in:
- lib/deepl/requests/translate.rb
Constant Summary collapse
- BOOLEAN_CONVERSION =
{ true => '1', false => '0' }.freeze
- ARRAY_CONVERSION =
->(value) { value.is_a?(Array) ? value.join(', ') : value }.freeze
- OPTIONS_CONVERSIONS =
{ split_sentences: BOOLEAN_CONVERSION, preserve_formatting: BOOLEAN_CONVERSION, non_splitting_tags: ARRAY_CONVERSION, ignore_tags: ARRAY_CONVERSION }.freeze
Instance Attribute Summary collapse
-
#ignore_tags ⇒ Object
readonly
Returns the value of attribute ignore_tags.
-
#non_splitting_tags ⇒ Object
readonly
Returns the value of attribute non_splitting_tags.
-
#source_lang ⇒ Object
readonly
Returns the value of attribute source_lang.
-
#target_lang ⇒ Object
readonly
Returns the value of attribute target_lang.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(api, text, source_lang, target_lang, options = {}) ⇒ Translate
constructor
A new instance of Translate.
- #request ⇒ Object
Constructor Details
#initialize(api, text, source_lang, target_lang, options = {}) ⇒ Translate
Returns a new instance of Translate.
15 16 17 18 19 20 21 22 |
# File 'lib/deepl/requests/translate.rb', line 15 def initialize(api, text, source_lang, target_lang, = {}) super(api, ) @text = text @source_lang = source_lang @target_lang = target_lang tweak_parameters! end |
Instance Attribute Details
#ignore_tags ⇒ Object (readonly)
Returns the value of attribute ignore_tags.
13 14 15 |
# File 'lib/deepl/requests/translate.rb', line 13 def @ignore_tags end |
#non_splitting_tags ⇒ Object (readonly)
Returns the value of attribute non_splitting_tags.
13 14 15 |
# File 'lib/deepl/requests/translate.rb', line 13 def @non_splitting_tags end |
#source_lang ⇒ Object (readonly)
Returns the value of attribute source_lang.
13 14 15 |
# File 'lib/deepl/requests/translate.rb', line 13 def source_lang @source_lang end |
#target_lang ⇒ Object (readonly)
Returns the value of attribute target_lang.
13 14 15 |
# File 'lib/deepl/requests/translate.rb', line 13 def target_lang @target_lang end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
13 14 15 |
# File 'lib/deepl/requests/translate.rb', line 13 def text @text end |
Instance Method Details
#request ⇒ Object
24 25 26 27 |
# File 'lib/deepl/requests/translate.rb', line 24 def request payload = { text: text, source_lang: source_lang, target_lang: target_lang } build_texts(*post(payload)) end |