class REST::Response
Response
holds a HTTP response
Constants
- CODES
These codes are used to define convenience boolean accessors on the response object.
Examples
REST::Response.new(200).ok? #=> true REST::Response.new(201).ok? #=> falses REST::Response.new(403).forbidden? #=> true
Attributes
body[RW]
headers[RW]
status_code[RW]
Public Class Methods
new(status_code, headers={}, body='')
click to toggle source
-
status_code
: The status code of the response (ie. 200 or ‘404’) -
headers
: The headers of the response -
body
: The body of the response
# File lib/rest/response.rb, line 29 def initialize(status_code, headers={}, body='') @status_code = status_code.to_i @headers = headers @body = body end
Public Instance Methods
success?()
click to toggle source
Returns true when the status code is in the 2XX range. Returns false otherwise.
# File lib/rest/response.rb, line 42 def success? (status_code.to_s =~ /2../) ? true : false end