class TwitterCldr::Formatters::Rbnf::MasterRuleFormatter
Public Instance Methods
close_bracket(number, rule, token)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 207 def close_bracket(number, rule, token) @omit = false "" end
left_arrow(number, rule, token)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 184 def left_arrow(number, rule, token) if is_fractional # is this necessary? RuleFormatter.format( (number * fractional_rule(number).base_value).to_i, rule_set, rule_group, locale ) else generate_replacement(integral_part(number), rule, token) end end
open_bracket(number, rule, token)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 196 def open_bracket(number, rule, token) @omit = if is_fractional # is this necessary? (number * fractional_rule(number).base_value) == 1 else # Omit the optional text if the number is an integer (same as specifying both an x.x rule and an x.0 rule) @omit = number.is_a?(Integer) end "" end
right_arrow(number, rule, token)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 172 def right_arrow(number, rule, token) # Format by digits. This is not explained in the main doc. See: # http://grepcode.com/file/repo1.maven.org/maven2/com.ibm.icu/icu4j/51.2/com/ibm/icu/text/NFSubstitution.java#FractionalPartSubstitution.%3Cinit%3E%28int%2Ccom.ibm.icu.text.NFRuleSet%2Ccom.ibm.icu.text.RuleBasedNumberFormat%2Cjava.lang.String%29 # doesn't seem to matter if the descriptor is two or three arrows, although three seems to indicate # we should or should not be inserting spaces somewhere (not sure where) is_fractional = true number.to_s.split(".")[1].each_char.map do |digit| RuleFormatter.format(digit.to_i, rule_set, rule_group, locale) end.join(" ") end
Protected Instance Methods
fractional_rule(number)
click to toggle source
# File lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb, line 214 def fractional_rule(number) @fractional_rule ||= rule_set.rule_for(number, true) end