Skip to content

Instantly share code, notes, and snippets.

@mkwiatkowski
Forked from gotar/gist:2643135
Created May 9, 2012 08:59
Show Gist options
  • Save mkwiatkowski/2643146 to your computer and use it in GitHub Desktop.
Save mkwiatkowski/2643146 to your computer and use it in GitHub Desktop.
rewrited
class WebRequest
MOBILE_USER_AGENTS = r/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/i
attr_reader :time, :ip, :referer, :user_agent
def initialize(time, ip, referer, user_agent)
@time = time
@ip = ip
@referer = referer
@user_agent = user_agent
@mobile = user_agent =~ MOBILE_USER_AGENTS
end
def mobile?
@mobile
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment