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
rubocop:disable Naming/AccessorMethodName.
-
.spell(locale, number, options = {}) ⇒ Object
Class Method Details
.clear_default_options ⇒ Object
18
19
20
|
# File 'lib/ffi-icu/number_formatting.rb', line 18
def self.clear_default_options
@default_options.clear
end
|
.create(locale, type = :decimal, options = {}) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/ffi-icu/number_formatting.rb', line 9
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
|
34
35
36
|
# File 'lib/ffi-icu/number_formatting.rb', line 34
def self.format_currency(locale, number, currency, options = {})
create(locale, :currency, options).format(number, currency)
end
|
26
27
28
|
# File 'lib/ffi-icu/number_formatting.rb', line 26
def self.format_number(locale, number, options = {})
create(locale, :decimal, options).format(number)
end
|
30
31
32
|
# File 'lib/ffi-icu/number_formatting.rb', line 30
def self.format_percent(locale, number, options = {})
create(locale, :percent, options).format(number)
end
|
.set_default_options(options) ⇒ Object
rubocop:disable Naming/AccessorMethodName
22
23
24
|
# File 'lib/ffi-icu/number_formatting.rb', line 22
def self.set_default_options(options) @default_options.merge!(options)
end
|
.spell(locale, number, options = {}) ⇒ Object
38
39
40
|
# File 'lib/ffi-icu/number_formatting.rb', line 38
def self.spell(locale, number, options = {})
create(locale, :spellout, options).format(number)
end
|