Class: Linguin::ProfanityDetection
- Inherits:
-
BaseResponse
- Object
- BaseResponse
- Linguin::ProfanityDetection
- Defined in:
- lib/linguin/profanity_detection.rb
Overview
Linguin::ProfanityDetection
Returned by Linguin#detect_profanity(!).
#success? - Bool - checks if detection results were found #error - Hash - contains ‘error` and `message` about what went wrong #result - Float - profanity score 0.0..1.0
Constant Summary
Constants inherited from BaseResponse
Instance Attribute Summary collapse
-
#score ⇒ Object
Returns the value of attribute score.
-
#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
#score ⇒ Object
Returns the value of attribute score.
12 13 14 |
# File 'lib/linguin/profanity_detection.rb', line 12 def score @score end |
#success=(value) ⇒ Object (writeonly)
Sets the attribute success
11 12 13 |
# File 'lib/linguin/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/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/profanity_detection.rb', line 25 def success(result) new do |detection| detection.success = true detection.score = result[:score] end end |
Instance Method Details
#success? ⇒ Boolean
33 34 35 |
# File 'lib/linguin/profanity_detection.rb', line 33 def success? !!@success end |