Class: Rubai::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status = 200, content_type = "text/html", body = []) ⇒ Response

Returns a new instance of Response.



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

def initialize(status = 200, content_type = "text/html", body=[])
  @status = status
  self.content_type= content_type
  @body = body
end

Instance Attribute Details

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/rubai/response.rb', line 3

def status
  @status
end

Class Method Details

.new_with_body(body) ⇒ Object



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

def self.new_with_body body
  self.new 200, "text/html", [body]
end

Instance Method Details

#<<(body_text) ⇒ Object



19
20
21
# File 'lib/rubai/response.rb', line 19

def <<(body_text)
  body << body_text
end

#bodyObject



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

def body
  @body ||= []
end

#content_typeObject



27
28
29
# File 'lib/rubai/response.rb', line 27

def content_type
  self["Content-Type"]
end

#content_type=(content_type) ⇒ Object



23
24
25
# File 'lib/rubai/response.rb', line 23

def content_type=(content_type)
  self["Content-Type"] = content_type
end

#headersObject



35
36
37
# File 'lib/rubai/response.rb', line 35

def headers
  @headers ||= {}
end