Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

HTTP User Agent parser

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
README.rdoc

UserAgent

UserAgent is a Ruby library that parses and compares HTTP User Agents.

Example

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 © 2009 Joshua Peek, released under the MIT license

Something went wrong with that request. Please try again.