Class: Cldr::Export::Data::Timezones
- Defined in:
- lib/cldr/export/data/timezones.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(locale) ⇒ Timezones
constructor
A new instance of Timezones.
- #metazones ⇒ Object
- #timezones ⇒ Object
Methods inherited from Base
Methods inherited from Hash
#deep_merge, #deep_stringify_keys, #symbolize_keys
Constructor Details
#initialize(locale) ⇒ Timezones
Returns a new instance of Timezones.
7 8 9 10 |
# File 'lib/cldr/export/data/timezones.rb', line 7 def initialize(locale) super update(:timezones => timezones, :metazones => ) end |
Instance Method Details
#metazones ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cldr/export/data/timezones.rb', line 26 def @metazones ||= select('dates/timeZoneNames/metazone').inject({}) do |result, zone| type = zone.attr('type').to_sym result[type] = {} long = nodes_to_hash(zone.xpath('long/*')) result[type][:long] = long unless long.empty? short = nodes_to_hash(zone.xpath('short/*')) result[type][:short] = short unless short.empty? result end end |
#timezones ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cldr/export/data/timezones.rb', line 12 def timezones @timezones ||= select('dates/timeZoneNames/zone').inject({}) do |result, zone| type = zone.attr('type').to_sym result[type] = {} long = nodes_to_hash(zone.xpath('long/*')) result[type][:long] = long unless long.empty? short = nodes_to_hash(zone.xpath('short/*')) result[type][:short] = short unless short.empty? city = select(zone, 'exemplarCity').first result[type][:city] = city.content if city result end end |