Class: Cldr::Data::Timezones

Inherits:
Base
  • Object
show all
Defined in:
lib/cldr/data/timezones.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) ⇒ Timezones

Returns a new instance of Timezones.



6
7
8
9
# File 'lib/cldr/data/timezones.rb', line 6

def initialize(locale)
  super
  self[:timezones] = timezones
end

Instance Method Details

#timezonesObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cldr/data/timezones.rb', line 11

def timezones
  @timezones ||= select('dates/timeZoneNames/zone').inject({}) do |result, zone|
    type = zone.attribute('type').value.to_sym
    city = select(zone, 'exemplarCity').first
    result[type] = {}
    # see en.xml, Europe/London, does not have an exemplarCity element
    # instead it has long and short daylight names which otherwise only
    # have metazones. (??)
    result[type][:city] = city.content if city
    result
  end
end