Module: Sentiero::UserAgent
- Defined in:
- lib/sentiero/user_agent.rb
Overview
User-Agent classifier into coarse buckets — good enough for distribution charts, not for precise version detection.
Class Method Summary collapse
Class Method Details
.browser(user_agent) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sentiero/user_agent.rb', line 20 def browser(user_agent) return if !user_agent || user_agent.empty? case user_agent when /Edg\//i then "Edge" when /OPR\//i, /Opera/i then "Opera" when /Chrome\//i then "Chrome" when /Safari\//i then "Safari" when /Firefox\//i then "Firefox" else "Other" end end |
.device(user_agent) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sentiero/user_agent.rb', line 9 def device(user_agent) return if !user_agent || user_agent.empty? if user_agent.match?(/Tablet|iPad/i) "Tablet" elsif user_agent.match?(/Mobile|Android|iPhone/i) "Mobile" else "Desktop" end end |