Module: BrowserDetection
- Defined in:
- lib/browser_detection.rb
Class Method Summary collapse
Class Method Details
.browser(user_agent) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/browser_detection.rb', line 4 def self.browser(user_agent) case user_agent when /Edg/i :edge when /Opera/i, /OPR/i :opera when /Firefox/i :firefox when /Chrome/i, /CriOS/i :chrome when /Safari/i :safari when /MSIE/i, /Trident/i :ie when /Discourse/i :discoursehub else :unknown end end |
.device(user_agent) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/browser_detection.rb', line 25 def self.device(user_agent) case user_agent when /Android/i :android when /CrOS/i :chromebook when /iPad/i :ipad when /iPhone/i :iphone when /iPod/i :ipod when /Mobile/i :mobile when /Macintosh/i :mac when /Linux/i :linux when /Windows/i :windows else :unknown end end |
.os(user_agent) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/browser_detection.rb', line 50 def self.os(user_agent) case user_agent when /Android/i :android when /CrOS/i :chromeos when /iPhone|iPad|iPod|Darwin/i :ios when /Macintosh/i :macos when /Linux/i :linux when /Windows/i :windows else :unknown end end |