Class: EasyTranslate::Detection::DetectionRequest
- Defined in:
- lib/easy_translate/detection.rb
Overview
A convenience class for wrapping a detection request
Instance Attribute Summary
Attributes inherited from Request
Instance Method Summary collapse
-
#body ⇒ String
The body for the request.
-
#initialize(texts, options = {}, http_options = {}) ⇒ DetectionRequest
constructor
Set the texts and options.
-
#multi? ⇒ Boolean
Whether or not this was a request for multiple texts.
-
#params ⇒ Hash
The params for this request.
-
#path ⇒ String
The path for the request.
Methods inherited from Request
Constructor Details
#initialize(texts, options = {}, http_options = {}) ⇒ DetectionRequest
Set the texts and options
36 37 38 39 40 41 42 |
# File 'lib/easy_translate/detection.rb', line 36 def initialize(texts, = {}, = {}) super(, ) if replacement_api_key = .delete(:api_key) [:key] = replacement_api_key end self.texts = texts end |
Instance Method Details
#body ⇒ String
The body for the request
60 61 62 |
# File 'lib/easy_translate/detection.rb', line 60 def body @texts.map { |t| "q=#{CGI::escape(t)}" }.join '&' end |
#multi? ⇒ Boolean
Whether or not this was a request for multiple texts
66 67 68 |
# File 'lib/easy_translate/detection.rb', line 66 def multi? @multi end |
#params ⇒ Hash
The params for this request
46 47 48 49 50 |
# File 'lib/easy_translate/detection.rb', line 46 def params params = super || {} params.merge! if params end |
#path ⇒ String
The path for the request
54 55 56 |
# File 'lib/easy_translate/detection.rb', line 54 def path '/language/translate/v2/detect' end |