Class: Presss::HTTP::Response
- Inherits:
-
Object
- Object
- Presss::HTTP::Response
- Defined in:
- lib/presss.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, headers, body = nil) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
Returns true when the status code is in the 2XX range.
Constructor Details
#initialize(status_code, headers, body = nil) ⇒ Response
Returns a new instance of Response.
38 39 40 |
# File 'lib/presss.rb', line 38 def initialize(status_code, headers, body=nil) @status_code, @headers, @body = status_code.to_i, headers, body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
36 37 38 |
# File 'lib/presss.rb', line 36 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
36 37 38 |
# File 'lib/presss.rb', line 36 def headers @headers end |
#status_code ⇒ Object
Returns the value of attribute status_code.
36 37 38 |
# File 'lib/presss.rb', line 36 def status_code @status_code end |
Instance Method Details
#success? ⇒ Boolean
Returns true when the status code is in the 2XX range. Returns false otherwise.
43 44 45 |
# File 'lib/presss.rb', line 43 def success? status_code >= 200 && status_code < 300 end |