Skip to content

Instantly share code, notes, and snippets.

@gotar
Created May 9, 2012 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gotar/2643135 to your computer and use it in GitHub Desktop.
Save gotar/2643135 to your computer and use it in GitHub Desktop.
rewrited
class WebRequest
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 = is_mobile?
end
def mobile?
@mobile
end
private
def is_mobile?
@user_agent =~ Regexp.new(
'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',
Regexp::IGNORECASE) ? true : false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment