Class: Adelnor::Response

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
# File 'lib/adelnor/response.rb', line 5

def initialize(status, headers, body)
  @status  = status
  @headers = headers
  @body    = body.respond_to?(:first) ? body.first : body
end

Class Method Details

.build(*args) ⇒ Object



11
12
13
# File 'lib/adelnor/response.rb', line 11

def self.build(*args)
  new(*args).build
end

Instance Method Details

#buildObject



15
16
17
# File 'lib/adelnor/response.rb', line 15

def build
  "HTTP/2.0 #{@status}\r\n#{headers_as_string}\r\n#{@body}"
end