Sha256: 61fbd749f4c3cf90d0f25591c3ad57735a182128c7b5d569d0df8e49b8fb93f1
Contents?: true
Size: 873 Bytes
Versions: 7
Compression:
Stored size: 873 Bytes
Contents
= UserAgent UserAgent is a Ruby library that parses and compares HTTP User Agents. === Installation gem install useragent === Examples ==== Reporting string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5' user_agent = UserAgent.parse(string) user_agent.browser # => 'Chrome' user_agent.version # => '19.0.1084.56' user_agent.platform # => 'Macintosh' user_agent.mobile? # => false ==== Comparison Browser = Struct.new(:browser, :version) SupportedBrowsers = [ Browser.new("Safari", "3.1.1"), Browser.new("Firefox", "2.0.0.14"), Browser.new("Internet Explorer", "7.0") ] user_agent = UserAgent.parse(request.user_agent) SupportedBrowsers.detect { |browser| user_agent >= browser } Copyright (c) 2009 Joshua Peek, released under the MIT license
Version data entries
7 entries across 7 versions & 1 rubygems