Created
November 5, 2011 17:33
-
-
Save britg/1341804 to your computer and use it in GitHub Desktop.
UA Detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_platform | |
return @current_platform if defined?(@current_platform) | |
return 'web' unless user_agent.present? | |
return (@current_platform = 'iphone') if user_agent.match('iphone') | |
return (@current_platform = 'android') if user_agent.match('android') | |
return (@current_platform = 'blackberry') if user_agent.match('blackberry') | |
if (user_agent.match('windowsphone') || user_agent.match('iemobile')) | |
return @current_platform = 'windows' | |
end | |
return @curent_platform = 'web' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment