Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/http.rb
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(code:, body: "") ⇒ Response
constructor
A new instance of Response.
- #send(client) ⇒ Object
Constructor Details
#initialize(code:, body: "") ⇒ Response
Returns a new instance of Response.
30 31 32 33 34 35 36 37 |
# File 'lib/http.rb', line 30 def initialize(code:, body: "") @code = code @response = "HTTP/1.1 #{code}\r\n" + "Content-Length: #{body.size}\r\n" + "\r\n" + "#{body}\r\n" end |
Instance Method Details
#code ⇒ Object
43 44 45 |
# File 'lib/http.rb', line 43 def code @code end |
#send(client) ⇒ Object
39 40 41 |
# File 'lib/http.rb', line 39 def send(client) client.write(@response) end |