Class: Linguin::BulkProfanityDetection
- Inherits:
-
BaseResponse
- Object
- BaseResponse
- Linguin::BulkProfanityDetection
- Defined in:
- lib/linguin/bulk_profanity_detection.rb
Overview
Linguin::BulkProfanityDetection
Returned by Linguin#detect_profanity(!) when called with an array of strings.
#success? - Bool - checks if detection results were found #error - Hash - contains ‘error` and `message` about what went wrong #results - Array - contains the profanity scores of each text in the same order
Constant Summary
Constants inherited from BaseResponse
Linguin::BaseResponse::CODE_MAP
Instance Attribute Summary collapse
-
#scores ⇒ Object
Returns the value of attribute scores.
-
#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
#scores ⇒ Object
Returns the value of attribute scores.
12 13 14 |
# File 'lib/linguin/bulk_profanity_detection.rb', line 12 def scores @scores end |
#success=(value) ⇒ Object (writeonly)
Sets the attribute success
11 12 13 |
# File 'lib/linguin/bulk_profanity_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/bulk_profanity_detection.rb', line 15 def error(code, ) new do |detection| detection.success = false detection.error = { code: code, message: } end end |
.success(result) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/linguin/bulk_profanity_detection.rb', line 25 def success(result) new do |detection| detection.success = true detection.scores = result[:scores] end end |
Instance Method Details
#success? ⇒ Boolean
33 34 35 |
# File 'lib/linguin/bulk_profanity_detection.rb', line 33 def success? !!@success end |