Class: Rack::DetectPlatform
- Inherits:
-
Object
- Object
- Rack::DetectPlatform
- Defined in:
- lib/rack/detect_platform.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ DetectPlatform
constructor
A new instance of DetectPlatform.
-
#platforms ⇒ Object
For the time being, Android is being identified as an iPhone.
Constructor Details
#initialize(app, options = {}) ⇒ DetectPlatform
Returns a new instance of DetectPlatform.
5 6 7 |
# File 'lib/rack/detect_platform.rb', line 5 def initialize(app, = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rack/detect_platform.rb', line 9 def call(env) user_agent = env['HTTP_USER_AGENT'].to_s platforms.each do |re, platform| if user_agent =~ re env['X_PLATFORM'] = platform break end end @app.call(env) end |
#platforms ⇒ Object
For the time being, Android is being identified as an iPhone. We’ll split this out later.
23 24 25 26 27 28 |
# File 'lib/rack/detect_platform.rb', line 23 def platforms { /(iPhone|Android)/ => 'iphone', /iPad/ => 'ipad' } end |