struct Athena::Negotiation::AcceptLanguage

Overview

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"

Defined in:

accept_language.cr

Constructors

Instance Method Summary

Instance methods inherited from struct Athena::Negotiation::BaseAccept

header : String header, normalized_header : String normalized_header, parameters : Hash(String, String) parameters, quality : Float32 quality

Constructor methods inherited from struct Athena::Negotiation::BaseAccept

new(header : String) new

Constructor Detail

def self.new(value : String) #

[View source]

Instance Method Detail

def 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]
def language_range : String #

Returns the language range this AcceptLanguage header represents.

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


[View source]
def region : String | Nil #

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]
def script : String | Nil #

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]