Class: Cldr::Export::Data::Timezones

Inherits:
Base
  • Object
show all
Defined in:
lib/cldr/export/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.



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

def initialize(locale)
  super
  update(:timezones => timezones, :metazones => metazones)
end

Instance Method Details

#metazonesObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cldr/export/data/timezones.rb', line 26

def metazones
  @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

#timezonesObject



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