Class: Web2Go::WebrickResponse
- Inherits:
-
Object
- Object
- Web2Go::WebrickResponse
- Defined in:
- lib/Web2Go/WebrickResponse.rb
Instance Method Summary collapse
- #add_cookie(name, value, domain = nil, path = nil, expires = nil) ⇒ Object
- #body=(content) ⇒ Object
- #content_type=(type) ⇒ Object
- #cookies ⇒ Object
- #failed ⇒ Object
-
#initialize(response) ⇒ WebrickResponse
constructor
A new instance of WebrickResponse.
- #redirect_to=(url) ⇒ Object
- #set_cookie(cookie) ⇒ Object
Constructor Details
#initialize(response) ⇒ WebrickResponse
Returns a new instance of WebrickResponse.
8 9 10 |
# File 'lib/Web2Go/WebrickResponse.rb', line 8 def initialize(response) @response = response end |
Instance Method Details
#add_cookie(name, value, domain = nil, path = nil, expires = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/Web2Go/WebrickResponse.rb', line 37 def (name,value,domain=nil,path=nil,expires=nil) = WEBrick::Cookie.new(name,value) .expires = expires unless expires.nil? .domain = domain unless domain.nil? .path = path.nil? ? '/' : path () end |
#body=(content) ⇒ Object
12 13 14 |
# File 'lib/Web2Go/WebrickResponse.rb', line 12 def body=(content) @response.body=(content) end |
#content_type=(type) ⇒ Object
16 17 18 |
# File 'lib/Web2Go/WebrickResponse.rb', line 16 def content_type=(type) @response['Content-Type'] = type end |
#cookies ⇒ Object
33 34 35 |
# File 'lib/Web2Go/WebrickResponse.rb', line 33 def @response. end |
#failed ⇒ Object
24 25 26 |
# File 'lib/Web2Go/WebrickResponse.rb', line 24 def failed @response.set_error(HTTPStatus::RC_NOT_FOUND) end |
#redirect_to=(url) ⇒ Object
20 21 22 |
# File 'lib/Web2Go/WebrickResponse.rb', line 20 def redirect_to=(url) @response.set_redirect(WEBrick::HTTPStatus[302],url) end |
#set_cookie(cookie) ⇒ Object
28 29 30 31 |
# File 'lib/Web2Go/WebrickResponse.rb', line 28 def () @response..delete_if { |item| item.name == .name } @response..push() end |