class PlzPlzIE::Middleware
Constants
- IEVR
Public Class Methods
new(app,options={})
click to toggle source
# File lib/plz_plz_ie/middleware.rb, line 5 def initialize(app,options={}) @app = app @lastest = options[:lastest] || 9 @template = options[:path] || File.expand_path("../templates/plz_plz_ie.html", __FILE__) end
Public Instance Methods
call(env)
click to toggle source
# File lib/plz_plz_ie/middleware.rb, line 11 def call(env) ua = env['HTTP_USER_AGENT'].to_s if has_seat?(ua) @app.call env else [500,{ "Content-Type" => "text/html; charset=utf-8" },[File.read(@template)]] end end
Private Instance Methods
has_seat?(ua)
click to toggle source
# File lib/plz_plz_ie/middleware.rb, line 21 def has_seat? ua !ua.empty? && (ua.match(IEVR).nil? || $1.split('.').first.to_i >= @lastest) end