Module: Mobile

Extended by:
ActiveSupport::Concern
Defined in:
lib/mobile.rb,
lib/mobile/version.rb

Constant Summary collapse

MOBILE_USER_AGENTS =
'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' +
'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' +
'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' +
'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' +
'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' +
'mobile'
VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#is_device?(type) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mobile.rb', line 22

def is_device?(type)
  request.user_agent.to_s.downcase.include?(type.to_s.downcase)
end

#is_mobile_device?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mobile.rb', line 18

def is_mobile_device?
  request.user_agent.to_s.downcase =~ Regexp.new(Mobile::MOBILE_USER_AGENTS)
end