Sha256: 5e630625542767d92d2353bbea608aeab24036a03b49467eaf41948671939b7c

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

class Browser
  module Devices
    # Detect if browser is iPhone.
    def iphone?
      !!(ua =~ /iPhone/)
    end

    # Detect if browser is iPad.
    def ipad?
      !!(ua =~ /iPad/)
    end

    # Detect if browser is iPod.
    def ipod?
      !!(ua =~ /iPod/)
    end

    def surface?
      windows_rt? && !!(ua =~ /Touch/)
    end

    # Detect if browser is tablet (currently iPad, Android, Surface or Playbook).
    def tablet?
      !!(ipad? || (android? && !detect_mobile?) || surface? || playbook?)
    end

    # Detect if browser is Kindle.
    def kindle?
      !!(ua =~ /Kindle/ || silk?)
    end

    # Detect if browser if a Blackberry Playbook tablet
    def playbook?
      !!(ua =~ /PlayBook/ and ua =~ /RIM Tablet/)
    end

    def windows_touchscreen_desktop?
      windows? && !!(ua =~ /Touch/)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
browser-0.4.1 lib/browser/methods/devices.rb
browser-0.4.0 lib/browser/methods/devices.rb