class Ingreedy::DictionaryCollection
Public Class Methods
new()
click to toggle source
# File lib/ingreedy/dictionary_collection.rb, line 6 def initialize @collection = {} end
Public Instance Methods
[]=(locale, attributes)
click to toggle source
# File lib/ingreedy/dictionary_collection.rb, line 10 def []=(locale, attributes) @collection[locale] = Dictionary.new(attributes) end
current()
click to toggle source
# File lib/ingreedy/dictionary_collection.rb, line 14 def current @collection[locale] ||= Dictionary.new load_yaml(locale) end
Private Instance Methods
i18n_gem_locale()
click to toggle source
# File lib/ingreedy/dictionary_collection.rb, line 24 def i18n_gem_locale I18n.locale if defined?(I18n) end
load_yaml(locale)
click to toggle source
# File lib/ingreedy/dictionary_collection.rb, line 28 def load_yaml(locale) path = File.expand_path( File.join(File.dirname(__FILE__), "dictionaries", "#{locale}.yml"), ) YAML.load_file(path) rescue Errno::ENOENT raise "No dictionary found for :#{locale} locale" end
locale()
click to toggle source
# File lib/ingreedy/dictionary_collection.rb, line 20 def locale Ingreedy.locale || i18n_gem_locale || :en end