Class: Linguin::LanguageDetection
- Inherits:
-
BaseResponse
- Object
- BaseResponse
- Linguin::LanguageDetection
- Defined in:
- lib/linguin/language_detection.rb
Overview
Linguin::LanguageDetection
Returned by Linguin#detect_language(!).
#success? - Bool - checks if detection results were found #error - Hash - contains ‘error` and `message` about what went wrong #results - Array - contains the detection results, ordered by confidence descending
Direct Known Subclasses
Constant Summary
Constants inherited from BaseResponse
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
-
#success ⇒ Object
writeonly
Sets the attribute success.
Attributes inherited from BaseResponse
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseResponse
from_httparty, #initialize, #raise_on_error!
Constructor Details
This class inherits a constructor from Linguin::BaseResponse
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
12 13 14 |
# File 'lib/linguin/language_detection.rb', line 12 def results @results end |
#success=(value) ⇒ Object (writeonly)
Sets the attribute success
11 12 13 |
# File 'lib/linguin/language_detection.rb', line 11 def success=(value) @success = value end |
Class Method Details
.error(code, message) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/linguin/language_detection.rb', line 15 def error(code, ) new do |detection| detection.success = false detection.error = { code: code, message: } end end |
.success(results) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/linguin/language_detection.rb', line 25 def success(results) new do |detection| detection.success = true detection.results = results[:results] end end |
Instance Method Details
#success? ⇒ Boolean
33 34 35 |
# File 'lib/linguin/language_detection.rb', line 33 def success? !!@success end |