Class: Cldr::Export::Data::Currencies
- Defined in:
- lib/cldr/export/data/currencies.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #currencies ⇒ Object
- #currency(node) ⇒ Object
-
#initialize(locale) ⇒ Currencies
constructor
A new instance of Currencies.
Methods inherited from Base
Methods inherited from Hash
#deep_merge, #deep_stringify_keys, #symbolize_keys
Constructor Details
#initialize(locale) ⇒ Currencies
Returns a new instance of Currencies.
5 6 7 8 |
# File 'lib/cldr/export/data/currencies.rb', line 5 def initialize(locale) super update(:currencies => currencies) end |
Instance Method Details
#currencies ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cldr/export/data/currencies.rb', line 10 def currencies select('numbers/currencies/*').inject({}) do |result, node| currency = self.currency(node) result[node.attribute('type').value.to_sym] = currency unless currency.empty? result end end |
#currency(node) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cldr/export/data/currencies.rb', line 18 def currency(node) data = select(node, 'displayName').inject({}) do |result, node| count = node.attribute('count') ? node.attribute('count').value.to_sym : :one result[count] = node.content unless draft?(node) result end symbol = select(node, 'symbol') data[:symbol] = symbol.first.content if symbol.length > 0 data end |