Class: Wee::Response

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

Direct Known Subclasses

ErrorResponse, GenericResponse

Constant Summary collapse

DEFAULT_HEADER =
{}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mime_type = 'text/html', content = '') ⇒ Response

Returns a new instance of Response.



18
19
20
21
22
23
# File 'lib/wee/response.rb', line 18

def initialize(mime_type = 'text/html', content='')
  @status = 200
  @header = DEFAULT_HEADER.dup
  self.content_type = mime_type
  @content = content 
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/wee/response.rb', line 7

def content
  @content
end

#headerObject (readonly)

Returns the value of attribute header.



8
9
10
# File 'lib/wee/response.rb', line 8

def header
  @header
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/wee/response.rb', line 7

def status
  @status
end

Instance Method Details

#<<(str) ⇒ Object



33
34
35
# File 'lib/wee/response.rb', line 33

def <<(str)
  @content << str
end

#content_typeObject



25
26
27
# File 'lib/wee/response.rb', line 25

def content_type
  @header['Content-Type']
end

#content_type=(mime_type) ⇒ Object



29
30
31
# File 'lib/wee/response.rb', line 29

def content_type=(mime_type)
  @header['Content-Type'] = mime_type
end

#cookiesObject



14
15
16
# File 'lib/wee/response.rb', line 14

def cookies
  @cookies ||= []   
end

#cookies?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/wee/response.rb', line 10

def cookies?
  @cookies
end