Class: Web2Go::CGIResponse
- Inherits:
-
Object
- Object
- Web2Go::CGIResponse
- Defined in:
- lib/Web2Go/CGIResponse.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
Instance Method Summary collapse
- #add_cookie(name, value, domain = nil, path = nil, expires = nil) ⇒ Object
- #add_cookies(cookies) ⇒ Object
- #body=(content) ⇒ Object
- #cookies ⇒ Object
-
#initialize(cgi) ⇒ CGIResponse
constructor
A new instance of CGIResponse.
- #redirect_to=(redirect_url) ⇒ Object
- #set_cookie(cookie) ⇒ Object
Constructor Details
#initialize(cgi) ⇒ CGIResponse
Returns a new instance of CGIResponse.
9 10 11 12 13 |
# File 'lib/Web2Go/CGIResponse.rb', line 9 def initialize(cgi) @cgi = cgi @content_type = 'text/html' @redirect = nil end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/Web2Go/CGIResponse.rb', line 7 def content_type @content_type end |
Instance Method Details
#add_cookie(name, value, domain = nil, path = nil, expires = nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/Web2Go/CGIResponse.rb', line 46 def (name,value,domain=nil,path=nil,expires=nil) = CGI::Cookie.new(name,value) .expires = expires unless expires.nil? .domain = domain unless domain.nil? .path = path unless path.nil? () end |
#add_cookies(cookies) ⇒ Object
54 55 56 57 58 |
# File 'lib/Web2Go/CGIResponse.rb', line 54 def () # cookies.each do |cookie| # set_cookie(cookie) # end end |
#body=(content) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/Web2Go/CGIResponse.rb', line 19 def body=(content) = Hash.new ['type'] = @content_type if @cgi..length > 0 then ['cookie'] = @cgi. end if !@redirect.nil? then ['Status'] = '302 Moved' [ 'location'] = @redirect end @cgi.out() do content end end |
#cookies ⇒ Object
42 43 44 |
# File 'lib/Web2Go/CGIResponse.rb', line 42 def @cgi. end |
#redirect_to=(redirect_url) ⇒ Object
15 16 17 |
# File 'lib/Web2Go/CGIResponse.rb', line 15 def redirect_to=(redirect_url) @redirect = redirect_url end |
#set_cookie(cookie) ⇒ Object
38 39 40 |
# File 'lib/Web2Go/CGIResponse.rb', line 38 def () @cgi.[.name] = end |