Sha256: 02f0b5677cbc20c6d8a91e7fa5a337b87b396afd7161b5a3514051df359f2555

Contents?: true

Size: 457 Bytes

Versions: 5

Compression:

Stored size: 457 Bytes

Contents

class Browser
  module Mobile
    # Detect if browser is mobile.
    def mobile?
      detect_mobile? && !tablet?
    end

    # Detect if browser is Opera Mini.
    def opera_mini?
      !!(ua =~ /Opera Mini/)
    end

    # Detect if browser is BlackBerry
    def blackberry?
      !!(ua =~ /BlackBerry/)
    end

    private
    def detect_mobile?
      ua =~ /(Mobi(le)?|Symbian|MIDP|Windows CE)/ || blackberry? || psp? || opera_mini?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
browser-0.3.2 lib/browser/methods/mobile.rb
browser-0.3.1 lib/browser/methods/mobile.rb
browser-0.3.0 lib/browser/methods/mobile.rb
browser-0.2.1 lib/browser/methods/mobile.rb
browser-0.2.0 lib/browser/methods/mobile.rb