Class: Cldr::Data::Numbers
- Inherits:
-
Base
show all
- Defined in:
- lib/cldr/data/numbers.rb
Instance Attribute Summary
Attributes inherited from Base
#locale
Instance Method Summary
collapse
Methods inherited from Base
#[]=, #update
Methods inherited from Hash
#deep_merge, #deep_stringify_keys, #symbolize_keys
Constructor Details
#initialize(locale) ⇒ Numbers
Returns a new instance of Numbers.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/cldr/data/numbers.rb', line 4
def initialize(locale)
super
self[:'numbers.symbols'] = symbols
self[:'numbers.formats'] = {
:decimal => {
:patterns => {
:default => format('decimal')
}
},
:scientific => {
:patterns => {
:default => format('scientific')
}
},
:percent => {
:patterns => {
:default => format('percent')
}
},
:currency => {
:patterns => {
:default => format('currency')
}
},
}
self[:'numbers.formats.currency.unit'] = unit
end
|
Instance Method Details
#currency ⇒ Object
32
33
34
35
36
|
# File 'lib/cldr/data/numbers.rb', line 32
def currency
currency = format('currency')
currency.update(:unit => unit) unless unit.empty?
currency
end
|
45
46
47
48
49
|
# File 'lib/cldr/data/numbers.rb', line 45
def format(type)
select("numbers/#{type}Formats/#{type}FormatLength/#{type}Format/pattern").inject({}) do |result, node|
node.content unless draft?(node)
end
end
|
#symbols ⇒ Object
38
39
40
41
42
43
|
# File 'lib/cldr/data/numbers.rb', line 38
def symbols
select('numbers/symbols/*').inject({}) do |result, node|
result[name(node).to_sym] = node.content unless draft?(node)
result
end
end
|
#unit ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/cldr/data/numbers.rb', line 51
def unit
@unit ||= select("numbers/currencyFormats/unitPattern").inject({}) do |result, node|
count = node.attribute('count').value rescue 'one'
result[count] = node.content
result
end
end
|