Module: HumanUserAgent
- Extended by:
- HumanUserAgent
- Included in:
- HumanUserAgent
- Defined in:
- lib/human_user_agent.rb,
lib/human_user_agent/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
Instance Method Details
#parse(raw_user_agent) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/human_user_agent.rb', line 6 def parse(raw_user_agent) return nil if raw_user_agent.nil? || raw_user_agent == "" raw_user_agent = raw_user_agent.to_s if raw_user_agent =~ /MSIE (\d*\.\d*);/ "IE #{$1}" else uas = UserAgent.parse(raw_user_agent) if uas[-2] && uas[-2].product =~ /Chrome/ "Chrome" else ua = uas[-1] "#{ua.product} #{ua.version.to_s.split(".")[0..1].join(".")}" end end end |