Class: TwitterCldr::Resources::Loader
- Inherits:
-
Object
- Object
- TwitterCldr::Resources::Loader
- Defined in:
- lib/twitter_cldr/resources/loader.rb
Instance Method Summary collapse
- #get_locale_resource(locale, resource_name) ⇒ Object
- #get_resource(*path) ⇒ Object
- #locale_resource_loaded?(locale, resource_name) ⇒ Boolean
- #preload_all_resources ⇒ Object
- #preload_resource_for_locales(resource, *locales) ⇒ Object
- #preload_resources_for_all_locales(*resources) ⇒ Object
- #preload_resources_for_locale(locale, *resources) ⇒ Object
- #resource_loaded?(*path) ⇒ Boolean
- #resource_types ⇒ Object
Instance Method Details
#get_locale_resource(locale, resource_name) ⇒ Object
15 16 17 |
# File 'lib/twitter_cldr/resources/loader.rb', line 15 def get_locale_resource(locale, resource_name) get_resource(*locale_resource_path(locale, resource_name)) end |
#get_resource(*path) ⇒ Object
11 12 13 |
# File 'lib/twitter_cldr/resources/loader.rb', line 11 def get_resource(*path) resources_cache[resource_file_path(path)] end |
#locale_resource_loaded?(locale, resource_name) ⇒ Boolean
23 24 25 |
# File 'lib/twitter_cldr/resources/loader.rb', line 23 def locale_resource_loaded?(locale, resource_name) resource_loaded?(*locale_resource_path(locale, resource_name)) end |
#preload_all_resources ⇒ Object
55 56 57 58 59 60 |
# File 'lib/twitter_cldr/resources/loader.rb', line 55 def preload_all_resources TwitterCldr.supported_locales.each do |locale| preload_resources_for_locale(locale, :all) end nil end |
#preload_resource_for_locales(resource, *locales) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/twitter_cldr/resources/loader.rb', line 41 def preload_resource_for_locales(resource, *locales) locales.each do |locale| preload_resources_for_locale(locale, resource) end nil end |
#preload_resources_for_all_locales(*resources) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/twitter_cldr/resources/loader.rb', line 48 def preload_resources_for_all_locales(*resources) TwitterCldr.supported_locales.each do |locale| preload_resources_for_locale(locale, *resources) end nil end |
#preload_resources_for_locale(locale, *resources) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/twitter_cldr/resources/loader.rb', line 33 def preload_resources_for_locale(locale, *resources) if resources.size > 0 resources = resource_types if resources.first == :all resources.each { |res| get_locale_resource(locale, res) } end nil end |
#resource_loaded?(*path) ⇒ Boolean
19 20 21 |
# File 'lib/twitter_cldr/resources/loader.rb', line 19 def resource_loaded?(*path) resources_cache.include?(resource_file_path(path)) end |
#resource_types ⇒ Object
27 28 29 30 31 |
# File 'lib/twitter_cldr/resources/loader.rb', line 27 def resource_types @resource_types ||= Dir.glob(File.join(RESOURCES_DIR, 'locales/en', '*')).map do |file| File.basename(file).chomp(File.extname(file)).to_sym end end |