Module: Browser::Platform
- Included in:
- Browser
- Defined in:
- lib/browser/methods/platform.rb
Instance Method Summary collapse
-
#android? ⇒ Boolean
Detect if browser is Android.
-
#blackberry10? ⇒ Boolean
Detect if is BlackBerry 10.
-
#blackberry4? ⇒ Boolean
Detect if is BlackBerry 4.
-
#blackberry5? ⇒ Boolean
Detect if is BlackBerry 5.
-
#blackberry6? ⇒ Boolean
Detect if is BlackBerry 6.
-
#blackberry7? ⇒ Boolean
Detect if is BlackBerry 7.
-
#chrome_os? ⇒ Boolean
Detect if current platform is ChromeOS.
-
#ios4? ⇒ Boolean
Detect if is iOS4.
-
#ios5? ⇒ Boolean
Detect if is iOS5.
-
#ios6? ⇒ Boolean
Detect if is iOS6.
-
#ios7? ⇒ Boolean
Detect if is iOS7.
-
#ios8? ⇒ Boolean
Detect if is iOS8.
-
#ios? ⇒ Boolean
Detect if browser is ios?.
-
#linux? ⇒ Boolean
Detect if current platform is Linux flavor.
-
#mac? ⇒ Boolean
Detect if current platform is Macintosh.
-
#platform ⇒ Object
Return the platform.
- #windows10? ⇒ Boolean
- #windows7? ⇒ Boolean
- #windows8? ⇒ Boolean
- #windows8_1? ⇒ Boolean
-
#windows? ⇒ Boolean
Detect if current platform is Windows.
-
#windows_mobile? ⇒ Boolean
Detect if current platform is Windows Mobile.
-
#windows_phone? ⇒ Boolean
Detect if current platform is Windows Phone.
- #windows_rt? ⇒ Boolean
- #windows_vista? ⇒ Boolean
- #windows_wow64? ⇒ Boolean
-
#windows_x64? ⇒ Boolean
Detect if current platform is Windows in 64-bit architecture.
- #windows_x64_inclusive? ⇒ Boolean
-
#windows_xp? ⇒ Boolean
More info here => msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken.
Instance Method Details
#android? ⇒ Boolean
Detect if browser is Android.
4 5 6 |
# File 'lib/browser/methods/platform.rb', line 4 def android? !!(ua =~ /Android/ && !opera?) end |
#blackberry10? ⇒ Boolean
Detect if is BlackBerry 10.
59 60 61 |
# File 'lib/browser/methods/platform.rb', line 59 def blackberry10? !!(ua =~ /BB10/) end |
#blackberry4? ⇒ Boolean
Detect if is BlackBerry 4.
39 40 41 |
# File 'lib/browser/methods/platform.rb', line 39 def blackberry4? blackberry? && !!(ua =~ %r[BlackBerry\d+/4]) end |
#blackberry5? ⇒ Boolean
Detect if is BlackBerry 5.
44 45 46 |
# File 'lib/browser/methods/platform.rb', line 44 def blackberry5? blackberry? && !!(ua =~ %r[BlackBerry\d+/5]) end |
#blackberry6? ⇒ Boolean
Detect if is BlackBerry 6.
49 50 51 |
# File 'lib/browser/methods/platform.rb', line 49 def blackberry6? blackberry? && !!(ua =~ %r[Version/6]) end |
#blackberry7? ⇒ Boolean
Detect if is BlackBerry 7.
54 55 56 |
# File 'lib/browser/methods/platform.rb', line 54 def blackberry7? blackberry? && !!(ua =~ %r[Version/7]) end |
#chrome_os? ⇒ Boolean
Detect if current platform is ChromeOS
131 132 133 |
# File 'lib/browser/methods/platform.rb', line 131 def chrome_os? !!(ua =~ /CrOS/) end |
#ios4? ⇒ Boolean
Detect if is iOS4.
14 15 16 |
# File 'lib/browser/methods/platform.rb', line 14 def ios4? ios? && !!(ua =~ /OS 4/) end |
#ios5? ⇒ Boolean
Detect if is iOS5.
19 20 21 |
# File 'lib/browser/methods/platform.rb', line 19 def ios5? ios? && !!(ua =~ /OS 5/) end |
#ios6? ⇒ Boolean
Detect if is iOS6.
24 25 26 |
# File 'lib/browser/methods/platform.rb', line 24 def ios6? ios? && !!(ua =~ /OS 6/) end |
#ios7? ⇒ Boolean
Detect if is iOS7.
29 30 31 |
# File 'lib/browser/methods/platform.rb', line 29 def ios7? ios? && !!(ua =~ /OS 7/) end |
#ios8? ⇒ Boolean
Detect if is iOS8.
34 35 36 |
# File 'lib/browser/methods/platform.rb', line 34 def ios8? ios? && !!(ua =~ /OS 8/) end |
#ios? ⇒ Boolean
Detect if browser is ios?.
9 10 11 |
# File 'lib/browser/methods/platform.rb', line 9 def ios? ipod? || ipad? || iphone? end |
#linux? ⇒ Boolean
Detect if current platform is Linux flavor.
126 127 128 |
# File 'lib/browser/methods/platform.rb', line 126 def linux? !!(ua =~ /Linux/) end |
#mac? ⇒ Boolean
Detect if current platform is Macintosh.
64 65 66 |
# File 'lib/browser/methods/platform.rb', line 64 def mac? !!(ua =~ /Mac OS X/ && !ios?) end |
#platform ⇒ Object
Return the platform.
136 137 138 139 140 141 142 143 144 |
# File 'lib/browser/methods/platform.rb', line 136 def platform case when linux? then :linux when mac? then :mac when windows? then :windows else :other end end |
#windows10? ⇒ Boolean
94 95 96 |
# File 'lib/browser/methods/platform.rb', line 94 def windows10? windows? && !!(ua =~ /Windows NT 10/) end |
#windows7? ⇒ Boolean
82 83 84 |
# File 'lib/browser/methods/platform.rb', line 82 def windows7? windows? && !!(ua =~ /Windows NT 6.1/) end |
#windows8? ⇒ Boolean
86 87 88 |
# File 'lib/browser/methods/platform.rb', line 86 def windows8? windows? && !!(ua =~ /Windows NT 6.[2-3]/) end |
#windows8_1? ⇒ Boolean
90 91 92 |
# File 'lib/browser/methods/platform.rb', line 90 def windows8_1? windows? && !!(ua =~ /Windows NT 6\.3/) end |
#windows? ⇒ Boolean
Detect if current platform is Windows.
69 70 71 |
# File 'lib/browser/methods/platform.rb', line 69 def windows? !!(ua =~ /Windows/) end |
#windows_mobile? ⇒ Boolean
Detect if current platform is Windows Mobile.
103 104 105 |
# File 'lib/browser/methods/platform.rb', line 103 def windows_mobile? !!(ua =~ /Windows CE/) end |
#windows_phone? ⇒ Boolean
Detect if current platform is Windows Phone.
108 109 110 |
# File 'lib/browser/methods/platform.rb', line 108 def windows_phone? !!(ua =~ /Windows Phone/) end |
#windows_rt? ⇒ Boolean
98 99 100 |
# File 'lib/browser/methods/platform.rb', line 98 def windows_rt? windows8? && !!(ua =~ /ARM/) end |
#windows_vista? ⇒ Boolean
78 79 80 |
# File 'lib/browser/methods/platform.rb', line 78 def windows_vista? windows? && !!(ua =~ /Windows NT 6.0/) end |
#windows_wow64? ⇒ Boolean
117 118 119 |
# File 'lib/browser/methods/platform.rb', line 117 def windows_wow64? windows? && !!(ua =~ /WOW64/i) end |
#windows_x64? ⇒ Boolean
Detect if current platform is Windows in 64-bit architecture.
113 114 115 |
# File 'lib/browser/methods/platform.rb', line 113 def windows_x64? windows? && !!(ua =~ /(Win64|x64)/) && !!(ua =~ /x64/) end |
#windows_x64_inclusive? ⇒ Boolean
121 122 123 |
# File 'lib/browser/methods/platform.rb', line 121 def windows_x64_inclusive? windows_x64? || windows_wow64? end |
#windows_xp? ⇒ Boolean
More info here => msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken
74 75 76 |
# File 'lib/browser/methods/platform.rb', line 74 def windows_xp? windows? && !!(ua =~ /Windows NT 5.1/) end |