Class: NRB::BCSInterrogator::API::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Response

Returns a new instance of Response.



13
14
15
16
17
# File 'lib/bcs_interrogator/api/response.rb', line 13

def initialize(args)
  @status = args[:status]
  @body = process_body args[:body]
  @headers = args[:headers]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/bcs_interrogator/api/response.rb', line 6

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/bcs_interrogator/api/response.rb', line 6

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/bcs_interrogator/api/response.rb', line 6

def status
  @status
end

Instance Method Details

#errored?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/bcs_interrogator/api/response.rb', line 8

def errored?
  ! success?
end

#server_versionObject



20
21
22
# File 'lib/bcs_interrogator/api/response.rb', line 20

def server_version
  @headers.nil? ? "" : @headers["server"].sub(/\s+\(http:\/\/www\.embeddedcc\.com\)$/, '')
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/bcs_interrogator/api/response.rb', line 25

def success?
  @status >= 200 && @status < 300
end