Class: Cldr::Data::Currencies
- Defined in:
- lib/cldr/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.
4 5 6 7 |
# File 'lib/cldr/data/currencies.rb', line 4 def initialize(locale) super self[:currencies] = currencies end |
Instance Method Details
#currencies ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cldr/data/currencies.rb', line 9 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
17 18 19 20 21 22 23 |
# File 'lib/cldr/data/currencies.rb', line 17 def currency(node) 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 end |