Class: Cldr::Data::Units
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(locale) ⇒ Units
constructor
A new instance of Units.
- #unit(node) ⇒ Object
- #units ⇒ Object
Methods inherited from Base
Methods inherited from Hash
#deep_merge, #deep_stringify_keys, #symbolize_keys
Constructor Details
#initialize(locale) ⇒ Units
Returns a new instance of Units.
4 5 6 7 |
# File 'lib/cldr/data/units.rb', line 4 def initialize(locale) super self[:units] = units end |
Instance Method Details
#unit(node) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cldr/data/units.rb', line 16 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 |
#units ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cldr/data/units.rb', line 9 def units select('units/unit').inject({}) do |result, node| result[node.attribute('type').value.to_sym] = unit(node) result end end |