Class: Brut::I18n::HTTPAcceptLanguage::WeightedLocale
- Inherits:
-
Data
- Object
- Data
- Brut::I18n::HTTPAcceptLanguage::WeightedLocale
- Defined in:
- lib/brut/i18n/http_accept_language.rb
Overview
A locale with the weight (value for q=) it was given in the Accept-Language header
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
Instance Method Summary collapse
-
#==(other) ⇒ Object
-
#primary? ⇒ Boolean
True if this locale is a primary locale.
-
#primary_locale ⇒ Object
Returns the primary locale for whatever locale this is holding.
-
#primary_only ⇒ Object
Return a new WeightedLocale that is the primary locale.
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale
7 8 9 |
# File 'lib/brut/i18n/http_accept_language.rb', line 7 def locale @locale end |
#q ⇒ Object (readonly)
Returns the value of attribute q
7 8 9 |
# File 'lib/brut/i18n/http_accept_language.rb', line 7 def q @q end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/brut/i18n/http_accept_language.rb', line 21 def ==(other) self.locale == other.locale end |
#primary? ⇒ Boolean
True if this locale is a primary locale
14 |
# File 'lib/brut/i18n/http_accept_language.rb', line 14 def primary? = self.primary_locale == self.locale |
#primary_locale ⇒ Object
Returns the primary locale for whatever locale this is holding. For example, the primary locale of "en-US" is "en".
11 |
# File 'lib/brut/i18n/http_accept_language.rb', line 11 def primary_locale = self.locale.gsub(/\-.*$/,"") |
#primary_only ⇒ Object
Return a new WeightedLocale that is the primary locale.
17 18 19 |
# File 'lib/brut/i18n/http_accept_language.rb', line 17 def primary_only self.class.new(locale: self.primary_locale, q: self.q) end |