Class: Knowtify::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/knowtify/response.rb

Constant Summary collapse

ERROR_HTTP_CODES =
[500,501,502,503,504,505,429,0]

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/knowtify/response.rb', line 3

def body
  @body
end

#countObject

Returns the value of attribute count.



3
4
5
# File 'lib/knowtify/response.rb', line 3

def count
  @count
end

#http_codeObject

Returns the value of attribute http_code.



3
4
5
# File 'lib/knowtify/response.rb', line 3

def http_code
  @http_code
end

#raw_responseObject

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

Returns:

  • (Boolean)


15
16
17
# File 'lib/knowtify/response.rb', line 15

def retried?
  count != 0
end

#retry?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/knowtify/response.rb', line 19

def successful?
  http_code == 200
end