Class: DeepL::Requests::Rephrase
- Defined in:
- lib/deepl/requests/rephrase.rb
Instance Attribute Summary collapse
-
#target_lang ⇒ Object
readonly
Returns the value of attribute target_lang.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tone ⇒ Object
readonly
Returns the value of attribute tone.
-
#writing_style ⇒ Object
readonly
Returns the value of attribute writing_style.
Attributes inherited from Base
Instance Method Summary collapse
- #details ⇒ Object
-
#initialize(api, text, target_lang = nil, writing_style = nil, tone = nil, options = {}) ⇒ Rephrase
constructor
rubocop:disable Metrics/ParameterLists.
-
#request ⇒ Object
rubocop:disable Metrics/AbcSize.
- #to_s ⇒ Object
Constructor Details
#initialize(api, text, target_lang = nil, writing_style = nil, tone = nil, options = {}) ⇒ Rephrase
rubocop:disable Metrics/ParameterLists
11 12 13 14 15 16 17 |
# File 'lib/deepl/requests/rephrase.rb', line 11 def initialize(api, text, target_lang = nil, writing_style = nil, tone = nil, = {}) # rubocop:disable Metrics/ParameterLists super(api, ) @text = text @target_lang = target_lang @writing_style = writing_style @tone = tone end |
Instance Attribute Details
#target_lang ⇒ Object (readonly)
Returns the value of attribute target_lang.
9 10 11 |
# File 'lib/deepl/requests/rephrase.rb', line 9 def target_lang @target_lang end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/deepl/requests/rephrase.rb', line 9 def text @text end |
#tone ⇒ Object (readonly)
Returns the value of attribute tone.
9 10 11 |
# File 'lib/deepl/requests/rephrase.rb', line 9 def tone @tone end |
#writing_style ⇒ Object (readonly)
Returns the value of attribute writing_style.
9 10 11 |
# File 'lib/deepl/requests/rephrase.rb', line 9 def writing_style @writing_style end |
Instance Method Details
#details ⇒ Object
28 29 30 31 |
# File 'lib/deepl/requests/rephrase.rb', line 28 def details "HTTP Headers: #{headers}\nPayload #{{ text: text, target_lang: target_lang, writing_style: writing_style, tone: tone }}" end |
#request ⇒ Object
rubocop:disable Metrics/AbcSize
19 20 21 22 23 24 25 26 |
# File 'lib/deepl/requests/rephrase.rb', line 19 def request # rubocop:disable Metrics/AbcSize text_arrayified = text.is_a?(Array) ? text : [text] payload = { text: text_arrayified } payload[:target_lang] = target_lang unless target_lang.nil? payload[:writing_style] = writing_style unless writing_style.nil? payload[:tone] = tone unless tone.nil? build_texts(*execute_request_with_retries(post_request(payload))) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/deepl/requests/rephrase.rb', line 33 def to_s "POST #{uri.request_uri}" end |