Class: Hipbot::Http::Response

Inherits:
Struct
  • Object
show all
Defined in:
lib/hipbot/helpers/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Response

Returns a new instance of Response.



42
43
44
45
# File 'lib/hipbot/helpers/http.rb', line 42

def initialize *args
  super
  Hipbot.logger.debug("HTTP-RESPONSE: #{body}")
end

Instance Attribute Details

#raw_responseObject

Returns the value of attribute raw_response

Returns:

  • (Object)

    the current value of raw_response



41
42
43
# File 'lib/hipbot/helpers/http.rb', line 41

def raw_response
  @raw_response
end

Instance Method Details

#bodyObject



47
48
49
# File 'lib/hipbot/helpers/http.rb', line 47

def body
  raw_response.response
end

#codeObject



51
52
53
# File 'lib/hipbot/helpers/http.rb', line 51

def code
  raw_response.response_header.status
end

#headersObject



55
56
57
# File 'lib/hipbot/helpers/http.rb', line 55

def headers
  raw_response.response_header
end

#jsonObject



59
60
61
# File 'lib/hipbot/helpers/http.rb', line 59

def json
  @json ||= JSON.parse(body) || {}
end