Class: Cldr::Export::Data::Timezones
- Inherits:
-
Base
- Object
- Hash
- Base
- Cldr::Export::Data::Timezones
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
11
12
13
14
15
|
# File 'lib/cldr/export/data/timezones.rb', line 7
def initialize(locale)
super
update(
:formats => formats,
:timezones => timezones,
:metazones => metazones
)
end
|
Instance Method Details
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/cldr/export/data/timezones.rb', line 17
def formats
@formats ||= select('dates/timeZoneNames/*').inject({}) do |result, format|
if format.name.end_with?('Format')
underscored_name = format.name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
result[underscored_name] = format.text
end
result
end
end
|
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/cldr/export/data/timezones.rb', line 42
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
|
#timezones ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/cldr/export/data/timezones.rb', line 28
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
|