Sha256: 68c803bfef46e9d4fd9663d56dbb5e10b3adabe00588c19e2f4718754c32e45f

Contents?: true

Size: 688 Bytes

Versions: 7

Compression:

Stored size: 688 Bytes

Contents

##
# Defines all available locales.
module Anoubis::Core::Locales
  # List of all possible locales.
  LIST = {
    ru: { id: 1, name: 'Russian' },
    en: { id: 2, name: 'English' },
    kz: { id: 3, name: 'Kazakh' }
  }.freeze

  class << self
    ##
    # Returns the title of chosen locale
    # @param key [String] identificator of locale ('ru', 'en', etc.)
    # @return [String] english title of locale
    def name(key)
      LIST[key.to_sym][:name]
    end

    ##
    # Converts list of locales into enum attribute
    # @return [Symbol] return symbols array for all locales.
    def enums
      LIST.reduce({}) { |res, v| res.merge("#{v.first}": v.last[:id]) }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
anoubis-1.0.12 app/models/anoubis/core/locales.rb
anoubis-1.0.11 app/models/anoubis/core/locales.rb
anoubis-1.0.10 app/models/anoubis/core/locales.rb
anoubis-1.0.8 app/models/anoubis/core/locales.rb
anoubis-1.0.7 app/models/anoubis/core/locales.rb
anoubis-1.0.1 app/models/anoubis/core/locales.rb
anoubis-1.0.0 app/models/anoubis/core/locales.rb