Class: Lolita::Translation::Locales
- Inherits:
-
Object
- Object
- Lolita::Translation::Locales
- Includes:
- Enumerable
- Defined in:
- lib/lolita-translation/locales.rb
Instance Method Summary collapse
- #active ⇒ Object
- #by_resource_locale(resource) ⇒ Object
- #each ⇒ Object
-
#initialize(locale_names) ⇒ Locales
constructor
A new instance of Locales.
- #locale_names ⇒ Object
Constructor Details
#initialize(locale_names) ⇒ Locales
Returns a new instance of Locales.
9 10 11 |
# File 'lib/lolita-translation/locales.rb', line 9 def initialize(locale_names) @locale_names = locale_names end |
Instance Method Details
#active ⇒ Object
41 42 43 |
# File 'lib/lolita-translation/locales.rb', line 41 def active self.detect{|locale| locale.active?} end |
#by_resource_locale(resource) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lolita-translation/locales.rb', line 20 def by_resource_locale(resource) r_locale = resource_locale(resource) self.inject([]) do |result, locale| if r_locale.to_s == locale.name.to_s result.unshift(locale) else result.push(locale) end result end end |
#each ⇒ Object
13 14 15 16 17 18 |
# File 'lib/lolita-translation/locales.rb', line 13 def each populate_locales! @locales.each do |locale| yield locale end end |
#locale_names ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/lolita-translation/locales.rb', line 32 def locale_names l_names = if @locale_names.respond_to?(:call) @locale_names.call else @locale_names end l_names.sort end |