Class: Coarnotify::Http::NetHttpResponse

Inherits:
HttpResponse show all
Defined in:
lib/coarnotify/http.rb

Overview

Implementation of the HTTP response object using Net::HTTP

This wraps the Net::HTTP response object and provides the interface required by the client

Instance Method Summary collapse

Constructor Details

#initialize(resp) ⇒ NetHttpResponse

Construct the object as a wrapper around the original Net::HTTP response object

Parameters:

  • response object from Net::HTTP



121
122
123
# File 'lib/coarnotify/http.rb', line 121

def initialize(resp)
  @resp = resp
end

Instance Method Details

#header(header_name) ⇒ String

Get the value of a header from the response

Parameters:

  • the name of the header

Returns:

  • the header value



129
130
131
# File 'lib/coarnotify/http.rb', line 129

def header(header_name)
  @resp[header_name]
end

#net_http_responseNet::HTTPResponse

Get the original Net::HTTP response object

Returns:

  • the original response object



143
144
145
# File 'lib/coarnotify/http.rb', line 143

def net_http_response
  @resp
end

#status_codeInteger

Get the status code of the response

Returns:

  • the status code



136
137
138
# File 'lib/coarnotify/http.rb', line 136

def status_code
  @resp.code.to_i
end