Class: NRB::BCSInterrogator::API::Response
- Inherits:
-
Object
- Object
- NRB::BCSInterrogator::API::Response
- Defined in:
- lib/bcs_interrogator/api/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #errored? ⇒ Boolean
-
#initialize(args) ⇒ Response
constructor
A new instance of Response.
- #server_version ⇒ Object
- #success? ⇒ Boolean
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/bcs_interrogator/api/response.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/bcs_interrogator/api/response.rb', line 6 def headers @headers end |
#status ⇒ Object (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
8 9 10 |
# File 'lib/bcs_interrogator/api/response.rb', line 8 def errored? ! success? end |
#server_version ⇒ Object
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
25 26 27 |
# File 'lib/bcs_interrogator/api/response.rb', line 25 def success? @status >= 200 && @status < 300 end |