module CldrPlurals::RubyRuntime

Public Class Methods

build_args_for(num_str) click to toggle source
# File lib/cldr-plurals/ruby_runtime.rb, line 9
def build_args_for(num_str)
  num = StrNum.from_string(num_str)

  [
    n(num), i(num), f(num),
    t(num), v(num), w(num),
    e(num)
  ]
end
e(num) click to toggle source
# File lib/cldr-plurals/ruby_runtime.rb, line 49
def e(num)
  wrap(num).exp
end
f(num) click to toggle source

visible fractional digits in n, with trailing zeros.

# File lib/cldr-plurals/ruby_runtime.rb, line 30
def f(num)
  wrap(num).apply_exp.frac_val.to_i
end
i(num) click to toggle source

integer digits of n.

# File lib/cldr-plurals/ruby_runtime.rb, line 25
def i(num)
  wrap(num).apply_exp.int_val
end
n(num) click to toggle source

absolute value of the source number (integer and decimals).

# File lib/cldr-plurals/ruby_runtime.rb, line 20
def n(num)
  wrap(num).abs.strip.to_val
end
t(num) click to toggle source

visible fractional digits in n, without trailing zeros.

# File lib/cldr-plurals/ruby_runtime.rb, line 35
def t(num)
  wrap(num).apply_exp.strip.frac_val.to_i
end
v(num) click to toggle source

number of visible fraction digits in n, with trailing zeros.

# File lib/cldr-plurals/ruby_runtime.rb, line 40
def v(num)
  wrap(num).apply_exp.frac.length
end
w(num) click to toggle source

number of visible fraction digits in n, without trailing zeros.

# File lib/cldr-plurals/ruby_runtime.rb, line 45
def w(num)
  wrap(num).apply_exp.strip.frac_val.length
end

Private Class Methods

wrap(str_or_num) click to toggle source
# File lib/cldr-plurals/ruby_runtime.rb, line 55
def wrap(str_or_num)
  return str_or_num if str_or_num.is_a?(StrNum)
  StrNum.from_string(str_or_num)
end