Sha256: 34b0323d2e3a7f43469989723787f87dce3ad29d211c2aa3abbd03a47b0c4814

Contents?: true

Size: 1.02 KB

Versions: 20

Compression:

Stored size: 1.02 KB

Contents

# UserAgent

[![Build Status](https://travis-ci.org/gshutler/useragent.svg?branch=master)](https://travis-ci.org/gshutler/useragent)
[![Gem Version](https://badge.fury.io/rb/useragent.svg)](http://badge.fury.io/rb/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

20 entries across 20 versions & 2 rubygems

Version Path
rails-rfc6570-3.2.0 vendor/bundle/ruby/3.3.0/gems/useragent-0.16.10/README.md
useragent-0.16.10 README.md
useragent-0.16.9 README.md
useragent-0.16.8 README.md
useragent-0.16.7 README.md
useragent-0.16.6 README.md
useragent-0.16.5 README.md
useragent-0.16.4 README.md
useragent-0.16.3 README.md
useragent-0.16.2 README.md
useragent-0.16.1 README.md
useragent-0.16.0 README.md
useragent-0.15.2 README.md
useragent-0.15.1 README.md
useragent-0.15.0 README.md
useragent-0.14.0 README.md
useragent-0.13.3 README.md
useragent-0.13.2 README.md
useragent-0.13.1 README.md
useragent-0.13.0 README.md