class TwitterCldr::Formatters::Rbnf::RuleFormatter
Attributes
keep_soft_hyphens[RW]
Public Class Methods
format(number, rule_set, rule_group, locale)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 17 def format(number, rule_set, rule_group, locale) rule = rule_set.rule_for(number) formatter = formatter_for(rule, rule_set, rule_group, locale) result = formatter.format(number, rule) keep_soft_hyphens ? result : remove_soft_hyphens(result) end
formatter_for(rule, rule_set, rule_group, locale)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 24 def formatter_for(rule, rule_set, rule_group, locale) const = case rule.base_value when Rule::MASTER MasterRuleFormatter when Rule::IMPROPER_FRACTION ImproperFractionRuleFormatter when Rule::PROPER_FRACTION ProperFractionRuleFormatter when Rule::NEGATIVE NegativeRuleFormatter else NormalRuleFormatter end const.new(rule_set, rule_group, locale) end
Private Class Methods
remove_soft_hyphens(result)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 43 def remove_soft_hyphens(result) result.gsub([173].pack("U*"), "") end