Module: Browser::Devices

Included in:
Browser
Defined in:
lib/browser/methods/devices.rb

Instance Method Summary collapse

Instance Method Details

#ipad?Boolean

Detect if browser is iPad.

Returns:

  • (Boolean)


9
10
11
# File 'lib/browser/methods/devices.rb', line 9

def ipad?
  !!(ua =~ /iPad/)
end

#iphone?Boolean

Detect if browser is iPhone.

Returns:

  • (Boolean)


4
5
6
# File 'lib/browser/methods/devices.rb', line 4

def iphone?
  !!(ua =~ /iPhone/)
end

#ipod?Boolean

Detect if browser is iPod.

Returns:

  • (Boolean)


14
15
16
# File 'lib/browser/methods/devices.rb', line 14

def ipod?
  !!(ua =~ /iPod/)
end

#kindle?Boolean

Detect if browser is Kindle.

Returns:

  • (Boolean)


28
29
30
# File 'lib/browser/methods/devices.rb', line 28

def kindle?
  !!(ua =~ /Kindle/ || silk?)
end

#playbook?Boolean

Detect if browser if a Blackberry Playbook tablet

Returns:

  • (Boolean)


33
34
35
# File 'lib/browser/methods/devices.rb', line 33

def playbook?
  !!(ua =~ /PlayBook/ && ua =~ /RIM Tablet/)
end

#surface?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/browser/methods/devices.rb', line 18

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

#tablet?Boolean

Detect if browser is tablet (currently iPad, Android, Surface or Playbook).

Returns:

  • (Boolean)


23
24
25
# File 'lib/browser/methods/devices.rb', line 23

def tablet?
  !!(ipad? || (android? && !detect_mobile?) || surface? || playbook?)
end

#windows_touchscreen_desktop?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/browser/methods/devices.rb', line 37

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