Class: WebConsole::Response
- Inherits:
-
Struct
- Object
- Struct
- WebConsole::Response
- Defined in:
- lib/web_console/response.rb
Overview
A response object that writes content before the closing </body> tag, if possible.
The object quacks like Rack::Response.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
6 7 8 |
# File 'lib/web_console/response.rb', line 6 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
6 7 8 |
# File 'lib/web_console/response.rb', line 6 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status
6 7 8 |
# File 'lib/web_console/response.rb', line 6 def status @status end |
Instance Method Details
#finish ⇒ Object
19 20 21 |
# File 'lib/web_console/response.rb', line 19 def finish Rack::Response.new(body, status, headers).finish end |
#write(content) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/web_console/response.rb', line 7 def write(content) raw_body = Array(body).first.to_s if position = raw_body.rindex('</body>') raw_body.insert(position, content) else raw_body << content end self.body = raw_body end |