Skip to content

Instantly share code, notes, and snippets.

@britg
Created November 5, 2011 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britg/1341804 to your computer and use it in GitHub Desktop.
Save britg/1341804 to your computer and use it in GitHub Desktop.
UA Detect
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