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
- #body=(content) ⇒ Object
- #cookies ⇒ Object
- #failed ⇒ 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 14 |
# File 'lib/Web2Go/CGIResponse.rb', line 9 def initialize(cgi) @cgi = cgi @content_type = 'text/html' @redirect = nil = Hash.new 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
56 57 58 59 60 61 62 |
# File 'lib/Web2Go/CGIResponse.rb', line 56 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 |
#body=(content) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/Web2Go/CGIResponse.rb', line 20 def body=(content) = Hash.new ['type'] = @content_type if .length > 0 then ['cookie'] = end if !@redirect.nil? then ['Status'] = '302 Moved' ['location'] = @redirect end @cgi.out() do content end end |
#cookies ⇒ Object
52 53 54 |
# File 'lib/Web2Go/CGIResponse.rb', line 52 def end |
#failed ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/Web2Go/CGIResponse.rb', line 38 def failed = Hash.new ['type'] = @content_type ['Status'] = '404 Not Found' @cgi.out() do "" end end |
#redirect_to=(redirect_url) ⇒ Object
16 17 18 |
# File 'lib/Web2Go/CGIResponse.rb', line 16 def redirect_to=(redirect_url) @redirect = redirect_url end |
#set_cookie(cookie) ⇒ Object
47 48 49 50 |
# File 'lib/Web2Go/CGIResponse.rb', line 47 def () .delete(.name) [.name] = end |