Class: Knowtify::Response
- Inherits:
-
Object
- Object
- Knowtify::Response
- Defined in:
- lib/knowtify/response.rb
Constant Summary collapse
- ERROR_HTTP_CODES =
[500,501,502,503,504,505,429,0]
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#count ⇒ Object
Returns the value of attribute count.
-
#http_code ⇒ Object
Returns the value of attribute http_code.
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
Instance Method Summary collapse
-
#initialize(count = 0) ⇒ Response
constructor
A new instance of Response.
- #retried? ⇒ Boolean
- #retry? ⇒ Boolean
- #successful? ⇒ Boolean
Constructor Details
#initialize(count = 0) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/knowtify/response.rb', line 7 def initialize(count=0) @count = count || 0 end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def body @body end |
#count ⇒ Object
Returns the value of attribute count.
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def count @count end |
#http_code ⇒ Object
Returns the value of attribute http_code.
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def http_code @http_code end |
#raw_response ⇒ Object
Returns the value of attribute raw_response.
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def raw_response @raw_response end |
Instance Method Details
#retried? ⇒ Boolean
15 16 17 |
# File 'lib/knowtify/response.rb', line 15 def retried? count != 0 end |
#retry? ⇒ Boolean
11 12 13 |
# File 'lib/knowtify/response.rb', line 11 def retry? (((count + 1) <= Knowtify.config.max_retries) && ERROR_HTTP_CODES.include?(http_code)) end |
#successful? ⇒ Boolean
19 20 21 |
# File 'lib/knowtify/response.rb', line 19 def successful? http_code == 200 end |