class Rack::Chuck
Constants
- VERSION
Attributes
app[R]
Public Class Methods
new(app)
click to toggle source
# File lib/rack/chuck.rb, line 6 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/chuck.rb, line 19 def call(env) status, headers, response = app.call(env) headers["X-Chuck-Norris"] = fact unless facts.empty? [status, headers, response] end
fact()
click to toggle source
# File lib/rack/chuck.rb, line 14 def fact facts[rand(facts.length)].split(/\n/).join(' -- ') rescue end
facts()
click to toggle source
# File lib/rack/chuck.rb, line 10 def facts @@chuck ||= IO.read(File.expand_path('../chuck/facts.txt',__FILE__)).split(/\s*\n%\n\s*/) end