Class: IsItMobile
- Inherits:
-
Object
- Object
- IsItMobile
- Defined in:
- lib/is_it_mobile.rb
Defined Under Namespace
Modules: ForRails
Constant Summary collapse
- VERSION =
'1.0.1'
- POPULAR_MOBILE_USER_AGENT_BEGINNINGS =
['w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac', 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno','ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-', 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-','newt','noki','oper','palm','pana','pant','phil','play','port','prox', 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-', 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp','wapr','webc','winw','winw','xda','xda-']
Class Method Summary collapse
-
.mobile?(user_agent, accepts) ⇒ Boolean
Performs a few lightweight checks on the user agent to determine if it’s a mobile device.
Class Method Details
.mobile?(user_agent, accepts) ⇒ Boolean
Performs a few lightweight checks on the user agent to determine if it’s a mobile device.
7 8 9 10 11 |
# File 'lib/is_it_mobile.rb', line 7 def self.mobile?( user_agent, accepts ) return !!( user_agent =~ /(mobile|up.browser|up.link|mmp|symbian|phone|midp|wap|mini|ppc;|playstation|palm|wii|nitro)/i || accepts.index('application/vnd.wap.xhtml+xml') || POPULAR_MOBILE_USER_AGENT_BEGINNINGS.include?(user_agent[0,4])) end |