Class: Cldr::Export::Data::Units
- Inherits:
-
Base
- Object
- Hash
- Base
- Cldr::Export::Data::Units
show all
- Defined in:
- lib/cldr/export/data/units.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) ⇒ Units
Returns a new instance of Units.
5
6
7
8
9
10
11
12
13
|
# File 'lib/cldr/export/data/units.rb', line 5
def initialize(locale)
super
update(
:units => {
:unitLength => unitLength,
:durationUnit => durationUnit,
}
)
end
|
Instance Method Details
#durationUnit ⇒ Object
37
38
39
40
41
42
|
# File 'lib/cldr/export/data/units.rb', line 37
def durationUnit
select('units/durationUnit').inject({}) do |result, node|
result[node.attribute('type').value.to_sym] = node.xpath('durationUnitPattern').first.content
result
end
end
|
#unit(node) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/cldr/export/data/units.rb', line 29
def unit(node)
node.xpath('unitPattern').inject({}) do |result, node|
count = node.attribute('count') ? node.attribute('count').value.to_sym : :one
result[count] = node.content unless draft?(node)
result
end
end
|
#unitLength ⇒ Object
15
16
17
18
19
20
|
# File 'lib/cldr/export/data/units.rb', line 15
def unitLength
select('units/unitLength').inject({}) do |result, node|
result[node.attribute('type').value.to_sym] = units(node)
result
end
end
|
#units(node) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/cldr/export/data/units.rb', line 22
def units(node)
node.xpath('unit').inject({}) do |result, node|
result[node.attribute('type').value.to_sym] = unit(node)
result
end
end
|