Class: Rack::Closed

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Closed

Returns a new instance of Closed.



3
4
5
# File 'lib/rack/closed.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  hour = Time.now.hour

  if hour < 9 || hour > 17
    file = File.read("#{File.expand_path(File.dirname(__FILE__))}/views/closed.html")
    [503, {"Content-Type" => "text/html"}, file]
  else
    @app.call(env)
  end
end