Class: Rack::Hanoi

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/hanoi.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Hanoi

Returns a new instance of Hanoi.



5
6
7
# File 'lib/rack/hanoi.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/rack/hanoi.rb', line 9

def call(env)
  return (if md = env["PATH_INFO"].match(%r|^/hanoi/(\d+)|)
            height = md[1].to_i
            HanoiApp.new(true, height).call(env)
          else
            @app.call(env)
          end)
end