Class: Trustpilot::ErrorChecker
- Inherits:
-
Object
- Object
- Trustpilot::ErrorChecker
- Defined in:
- lib/trustpilot/error_checker.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #error_if_appropriate ⇒ Object
-
#initialize(response) ⇒ ErrorChecker
constructor
args: response: Net::HTTPResponse.
- #message ⇒ Object
Constructor Details
#initialize(response) ⇒ ErrorChecker
args:
response: Net::HTTPResponse
9 10 11 |
# File 'lib/trustpilot/error_checker.rb', line 9 def initialize response @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/trustpilot/error_checker.rb', line 5 def response @response end |
Instance Method Details
#body ⇒ Object
31 32 33 |
# File 'lib/trustpilot/error_checker.rb', line 31 def body response.body end |
#code ⇒ Object
27 28 29 |
# File 'lib/trustpilot/error_checker.rb', line 27 def code response.code.to_i end |
#error_if_appropriate ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trustpilot/error_checker.rb', line 13 def error_if_appropriate if code >= 500 init_error ServerError elsif code == 429 init_error RateLimitError elsif code == 401 init_error AuthenticationError elsif code >= 400 init_error ClientError elsif code >= 300 init_error ServerError end end |
#message ⇒ Object
35 36 37 |
# File 'lib/trustpilot/error_checker.rb', line 35 def response. end |