Class: NetNoop::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
# File 'lib/netnoop/response.rb', line 7

def initialize(http_response)
  @status   = http_response.code
  @body     = http_response.body
  @headers  = http_response.header.to_hash
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/netnoop/response.rb', line 4

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/netnoop/response.rb', line 5

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#content_typeObject



13
14
15
16
17
18
# File 'lib/netnoop/response.rb', line 13

def content_type
  if ct = headers['content-type']
    return ct.first if ct.is_a?(Array)
    return ct
  end
end