Module: HTTP::Accept::Languages

Defined in:
lib/http/accept/languages.rb

Defined Under Namespace

Classes: LanguageRange, Locales

Constant Summary collapse

LOCALE =
/\*|[A-Z]{1,8}(-[A-Z0-9]{1,8})*/i
QVALUE =
/0(\.[0-9]{0,6})?|1(\.[0]{0,6})?/
LANGUAGE_RANGE =
/(?<locale>#{LOCALE})(\s*;\s*q=(?<q>#{QVALUE}))?/

Class Method Summary collapse

Class Method Details

.parse(text) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/http/accept/languages.rb', line 104

def self.parse(text)
	scanner = StringScanner.new(text)
	
	languages = LanguageRange.parse(scanner)
	
	return Sort.by_quality_factor(languages)
end