Class: Utopia::Middleware::Requester::Response
- Inherits:
-
Object
- Object
- Utopia::Middleware::Requester::Response
- Defined in:
- lib/utopia/middleware/requester.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #body ⇒ Object
-
#initialize(status, headers, body) ⇒ Response
constructor
A new instance of Response.
- #okay? ⇒ Boolean
Constructor Details
#initialize(status, headers, body) ⇒ Response
Returns a new instance of Response.
19 20 21 22 23 |
# File 'lib/utopia/middleware/requester.rb', line 19 def initialize(status, headers, body) @status = status @headers = headers @body = body end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
26 27 28 |
# File 'lib/utopia/middleware/requester.rb', line 26 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
25 26 27 |
# File 'lib/utopia/middleware/requester.rb', line 25 def status @status end |
Instance Method Details
#[](key) ⇒ Object
42 43 44 |
# File 'lib/utopia/middleware/requester.rb', line 42 def [](key) return @headers[key] end |
#body ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/utopia/middleware/requester.rb', line 28 def body unless @body_string buffer = StringIO.new @body.each do |string| buffer.write(string) end @body_string = buffer.string end return @body_string end |
#okay? ⇒ Boolean
46 47 48 |
# File 'lib/utopia/middleware/requester.rb', line 46 def okay? @status == 200 end |