module ICU::NumberFormatting

Public Class Methods

clear_default_options() click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 16
def self.clear_default_options
  @default_options.clear
end
create(locale, type = :decimal, options = {}) click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 7
def self.create(locale, type = :decimal, options = {})
  case type
  when :currency
    CurrencyFormatter.new(locale, options.delete(:style)).set_attributes(@default_options.merge(options))
  else
    NumberFormatter.new(locale, type).set_attributes(@default_options.merge(options))
  end
end
format_currency(locale, number, currency, options = {}) click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 32
def self.format_currency(locale, number, currency, options = {})
  create(locale, :currency, options).format(number, currency)
end
format_number(locale, number, options = {}) click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 24
def self.format_number(locale, number, options = {})
  create(locale, :decimal, options).format(number)
end
format_percent(locale, number, options = {}) click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 28
def self.format_percent(locale, number, options = {})
  create(locale, :percent, options).format(number)
end
set_default_options(options) click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 20
def self.set_default_options(options)
  @default_options.merge!(options)
end
spell(locale, number, options = {}) click to toggle source
# File lib/ffi-icu/number_formatting.rb, line 36
def self.spell(locale, number, options = {})
  create(locale, :spellout, options).format(number)
end