Class: I18nLocales::Pair

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_locales.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(country, language, format = nil) ⇒ Pair

Returns a new instance of Pair.



59
60
61
62
63
# File 'lib/i18n_locales.rb', line 59

def initialize(country, language, format=nil)
  @country = country
  @language = language
  @format = format || I18nLocales.format
end

Instance Attribute Details

#countryObject

Returns the value of attribute country.



57
58
59
# File 'lib/i18n_locales.rb', line 57

def country
  @country
end

#formatObject

Returns the value of attribute format.



57
58
59
# File 'lib/i18n_locales.rb', line 57

def format
  @format
end

#languageObject

Returns the value of attribute language.



57
58
59
# File 'lib/i18n_locales.rb', line 57

def language
  @language
end

Instance Method Details

#to_sObject



65
66
67
68
69
70
71
# File 'lib/i18n_locales.rb', line 65

def to_s
  format.gsub('%C',  country.upcase)
        .gsub('%L', language.upcase)
        .gsub('%c',  country.downcase)
        .gsub('%l', language.downcase)
        .gsub('%%', '%')
end