Sha256: 58bba7fac3227a9f848672a355042abe4b7945280de2bbd6a2dea854e64ee8f3
Contents?: true
Size: 1.21 KB
Versions: 5
Compression:
Stored size: 1.21 KB
Contents
class UserAgent module Browsers module All include Comparable def <=>(other) if respond_to?(:browser) && other.respond_to?(:browser) && browser == other.browser version <=> other.version else false end end def eql?(other) self == other end def to_s to_str end def to_str join(" ") end def application first end def browser application.product end def version application.version end def respond_to?(symbol) detect_product(symbol) ? true : super end def method_missing(method, *args, &block) detect_product(method) || super end def webkit? false end def mobile? if browser == 'webOS' true elsif detect_product('Mobile') true elsif application.comment.detect { |k, v| k =~ /^IEMobile/ } true else false end end private def detect_product(product) detect { |useragent| useragent.product.to_s.downcase == product.to_s.downcase } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems