132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/football-timezones/timezones.rb', line 132
def find_zone( league:, season: )
raise ArgumentError, "league key as string|symbol expected" unless league.is_a?(String) || league.is_a?(Symbol)
@zones ||= begin
zones = {}
['timezones_africa',
'timezones_america',
'timezones_asia',
'timezones_europe',
'timezones_middle_east',
'timezones_pacific',
'timezones_world',].each do |name|
recs = read_csv( "#{SportDb::Module::Timezones.root}/config/#{name}.csv" )
recs.each do |rec|
zone = UTC.find_zone( rec['zone'] )
if zone.nil?
puts "!! ERROR - cannot find timezone in timezone db:"
pp rec
exit 1
end
zones[ rec['key']] = zone
end
end
zones
end
league_code = league.to_s.downcase
season = Season( season )
key = "#{league_code}+#{season}"
zone = @zones[key]
zone = @zones[league_code] if zone.nil?
if zone.nil?
code, _ = league_code.split( '.', 2 )
zone = @zones[code]
end
zone
end
|