Module: ICU::NumberFormatting
- Defined in:
- lib/ffi-icu/number_formatting.rb
Defined Under Namespace
Classes: BaseFormatter, CurrencyFormatter, NumberFormatter
Class Method Summary
collapse
-
.clear_default_options ⇒ Object
-
.create(locale, type = :decimal, options = {}) ⇒ Object
-
.format_currency(locale, number, currency, options = {}) ⇒ Object
-
.format_number(locale, number, options = {}) ⇒ Object
-
.format_percent(locale, number, options = {}) ⇒ Object
-
.set_default_options(options) ⇒ Object
-
.spell(locale, number, options = {}) ⇒ Object
Class Method Details
.clear_default_options ⇒ Object
16
17
18
|
# File 'lib/ffi-icu/number_formatting.rb', line 16
def self.clear_default_options
@default_options.clear
end
|
.create(locale, type = :decimal, options = {}) ⇒ Object
7
8
9
10
11
12
13
14
|
# 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
|
32
33
34
|
# 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
|
24
25
26
|
# File 'lib/ffi-icu/number_formatting.rb', line 24
def self.format_number(locale, number, options = {})
create(locale, :decimal, options).format(number)
end
|
28
29
30
|
# 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) ⇒ Object
20
21
22
|
# File 'lib/ffi-icu/number_formatting.rb', line 20
def self.set_default_options(options)
@default_options.merge!(options)
end
|
.spell(locale, number, options = {}) ⇒ Object
36
37
38
|
# File 'lib/ffi-icu/number_formatting.rb', line 36
def self.spell(locale, number, options = {})
create(locale, :spellout, options).format(number)
end
|