Module: AcceptLanguage

Defined in:
lib/accept_language.rb,
lib/accept_language/parser.rb,
lib/accept_language/matcher.rb

Overview

Tiny library for parsing the Accept-Language header.

Examples:

AcceptLanguage.parse("da, en-GB;q=0.8, en;q=0.7") # => #<AcceptLanguage::Parser:0x00007 @languages_range={"da"=>0.1e1, "en-GB"=>0.8e0, "en"=>0.7e0}>

See Also:

Defined Under Namespace

Classes: Matcher, Parser

Class Method Summary collapse

Class Method Details

.parse(field) ⇒ #match

Note:

Parse an Accept-Language header field into a language range.

Returns a parser that responds to #match.

Examples:

parse("da, en-GB;q=0.8, en;q=0.7") # => #<AcceptLanguage::Parser:0x00007 @languages_range={"da"=>0.1e1, "en-GB"=>0.8e0, "en"=>0.7e0}>

Returns:

  • (#match)

    a parser that responds to #match.


12
13
14
# File 'lib/accept_language.rb', line 12

def self.parse(field)
  Parser.new(field)
end