Skip to content

bookwyrm/useragent

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

HTTP User Agent parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%