Class: TDiary::Rack::HtmlAnchor
- Inherits:
-
Object
- Object
- TDiary::Rack::HtmlAnchor
- Defined in:
- lib/tdiary/rack/html_anchor.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ HtmlAnchor
constructor
A new instance of HtmlAnchor.
Constructor Details
#initialize(app) ⇒ HtmlAnchor
Returns a new instance of HtmlAnchor.
6 7 8 |
# File 'lib/tdiary/rack/html_anchor.rb', line 6 def initialize( app ) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tdiary/rack/html_anchor.rb', line 10 def call( env ) if env['PATH_INFO'].match(/(.*\/)([0-9\-]+)(p(\d\d))?\.html$/) env["PATH_INFO"] = $1 date = $2 anchor = $4 env["QUERY_STRING"] += "&" unless env["QUERY_STRING"].empty? env["QUERY_STRING"] += "date=#{date}" env["QUERY_STRING"] += "&p=#{anchor}" if anchor end @app.call( env ) end |