Skip to content

struct Athena::Negotiation::AcceptLanguage
inherits Athena::Negotiation::BaseAccept #

Represents an Accept-Language header character set.

accept = ANG::AcceptLanguage.new "zh-Hans-CN; q = 0.3; key=value"

accept.header            # => "zh-Hans-CN; q = 0.3; key=value"
accept.normalized_header # => "zh-Hans-CN; key=value"
accept.parameters        # => {"key" => "value"}
accept.quality           # => 0.3
accept.language          # => "zh"
accept.region            # => "cn"
accept.script            # => "hans"

Class methods#

.new(value : String) #

View source

Methods#

#language : String #

Returns the language for this AcceptLanguage header. E.x. if the #language_range is zh-Hans-CN, the language would be zh.

View source

#language_range : String #

Returns the language range this AcceptLanguage header represents.

I.e. #header minus the #quality and #parameters.

View source

#region : String? #

Returns the region, if any, for this AcceptLanguage header. E.x. if the #language_range is zh-Hans-CN, the region would be cn

View source

#script : String? #

Returns the script, if any, for this AcceptLanguage header. E.x. if the #language_range is zh-Hans-CN, the script would be hans

View source