Class: Presss::HTTP::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

Returns the value of attribute body.



36
37
38
# File 'lib/presss.rb', line 36

def body
  @body
end

#headersObject

Returns the value of attribute headers.



36
37
38
# File 'lib/presss.rb', line 36

def headers
  @headers
end

#status_codeObject

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.

Returns:

  • (Boolean)


43
44
45
# File 'lib/presss.rb', line 43

def success?
  status_code >= 200 && status_code < 300
end