Class: Linguin::Status
- Inherits:
-
BaseResponse
- Object
- BaseResponse
- Linguin::Status
- Defined in:
- lib/linguin/status.rb
Overview
Linguin::Status
Returned by Linguin#status.
- :
detections_today
: -
how many detections you performed today
- :
daily_limit
: -
your daily detection limit (or false)
- :
remaining_today
: -
detections remaining today (can be Float::INFINITY)
Constant Summary
Constants inherited from BaseResponse
Instance Attribute Summary collapse
-
#daily_limit ⇒ Object
Returns the value of attribute daily_limit.
-
#detections_today ⇒ Object
Returns the value of attribute detections_today.
-
#remaining_today ⇒ Object
Returns the value of attribute remaining_today.
Attributes inherited from BaseResponse
Class 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
#daily_limit ⇒ Object
Returns the value of attribute daily_limit.
11 12 13 |
# File 'lib/linguin/status.rb', line 11 def daily_limit @daily_limit end |
#detections_today ⇒ Object
Returns the value of attribute detections_today.
11 12 13 |
# File 'lib/linguin/status.rb', line 11 def detections_today @detections_today end |
#remaining_today ⇒ Object
Returns the value of attribute remaining_today.
11 12 13 |
# File 'lib/linguin/status.rb', line 11 def remaining_today @remaining_today end |
Class Method Details
.error(code, message) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/linguin/status.rb', line 14 def error(code, ) new do |status| status.error = { code: code, message: } end.raise_on_error! end |
.success(response) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/linguin/status.rb', line 23 def success(response) response = response[:status] detections_today = response[:detections_today].to_i daily_limit = response[:daily_limit] == -1 ? nil : response[:daily_limit].to_i remaining_today = response[:remaining_today] == -1 ? Float::INFINITY : response[:remaining_today].to_i new do |status| status.detections_today = detections_today status.daily_limit = daily_limit status.remaining_today = remaining_today end end |