Class: IsItMobile

Inherits:
Object
  • Object
show all
Defined in:
lib/is_it_mobile.rb

Defined Under Namespace

Modules: ForRails

Constant Summary collapse

VERSION =
'1.0.0.2'
['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

Class Method Details

.mobile?(user_agent, accepts) ⇒ Boolean

Check if the given user agent is for a mobile device.

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/is_it_mobile.rb', line 20

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