-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(README, code): add explanation of output after each example
- Loading branch information
Showing
14 changed files
with
157 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ jobs: | |
- 2.7 | ||
- 3.0 | ||
- 3.1 | ||
- 3.2 | ||
- head | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.7.6 | ||
3.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.0.3 | ||
2.0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
# Tiny library for parsing the Accept-Language header. | ||
# This module provides a tiny library for parsing the Accept-Language header as specified in RFC 2616. | ||
# It transforms the Accept-Language header field into a language range, providing a flexible way to determine | ||
# user's language preferences and match them with the available languages in your application. | ||
# | ||
# @example | ||
# 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}> | ||
# AcceptLanguage.parse("da, en-GB;q=0.8, en;q=0.7") | ||
# # => #<AcceptLanguage::Parser:0x00007 @languages_range={"da"=>1.0, "en-GB"=>0.8, "en"=>0.7}> | ||
# | ||
# @see https://tools.ietf.org/html/rfc2616#section-14.4 | ||
module AcceptLanguage | ||
# @note Parse an Accept-Language header field into a language range. | ||
# Parses an Accept-Language header field value into a Parser object, which can then be used to match | ||
# user's preferred languages against the languages your application supports. | ||
# This method accepts a string argument in the format as described in RFC 2616 Section 14.4, and returns | ||
# a Parser object which responds to the #match method. | ||
# | ||
# @param field [String] the Accept-Language header field value. | ||
# | ||
# @example | ||
# 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}> | ||
# @return [#match] a parser that responds to #match. | ||
# AcceptLanguage.parse("da, en-GB;q=0.8, en;q=0.7") | ||
# # => #<AcceptLanguage::Parser:0x00007 @languages_range={"da"=>1.0, "en-GB"=>0.8, "en"=>0.7}> | ||
# | ||
# @return [Parser] a Parser object that responds to #match method. | ||
def self.parse(field) | ||
Parser.new(field) | ||
end | ||
end | ||
|
||
# Load the Parser class | ||
require_relative File.join("accept_language", "parser") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.