Sha256: 6a28c4fd41c7658029881c2da55f98d2d0bef6ad5b511133c91a9953ce48fea1
Contents?: true
Size: 954 Bytes
Versions: 1
Compression:
Stored size: 954 Bytes
Contents
# UserAgent [![Build Status](https://travis-ci.org/gshutler/useragent.svg?branch=master)](https://travis-ci.org/gshutler/useragent) UserAgent is a Ruby library that parses and compares HTTP User Agents. ## Installation gem install useragent ### Examples #### Reporting ```ruby 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' ``` #### Comparison ```ruby 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) 2015 Garry Shutler, released under the MIT license
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
useragent-0.12.0 | README.md |