module TwitterCldr::Formatters::Plurals::Rules
Constants
- DEFAULT_TYPE
Public Class Methods
all(type = DEFAULT_TYPE)
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 17 def all(type = DEFAULT_TYPE) all_for(TwitterCldr.locale, type) end
all_for(locale, type = DEFAULT_TYPE)
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 21 def all_for(locale, type = DEFAULT_TYPE) names(locale, type) end
rule_for(number, locale = TwitterCldr.locale, type = DEFAULT_TYPE)
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 25 def rule_for(number, locale = TwitterCldr.locale, type = DEFAULT_TYPE) rule(locale, type).call(number.to_s, CldrPlurals::RubyRuntime) rescue :other end
Protected Class Methods
get_resource(locale)
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 33 def get_resource(locale) locale = TwitterCldr.convert_locale(locale) cache_key = TwitterCldr::Utils.compute_cache_key(locale) locale_cache[cache_key] ||= begin rsrc = TwitterCldr.get_locale_resource(locale, :plurals)[locale] rsrc.inject({}) do |ret, (rule_type, rule_data)| ret[rule_type] = rule_data.merge(rule: eval(rule_data[:rule])) ret end end end
locale_cache()
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 53 def locale_cache @locale_cache ||= {} end
names(locale, type)
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 49 def names(locale, type) get_resource(locale)[type][:names] end
rule(locale, type)
click to toggle source
# File lib/twitter_cldr/formatters/plurals/rules.rb, line 45 def rule(locale, type) get_resource(locale)[type][:rule] end