Class: CityTimeZone::SeedData
- Inherits:
-
Object
- Object
- CityTimeZone::SeedData
- Defined in:
- lib/city_time_zone/seed_data.rb
Constant Summary collapse
- FIELDS =
{ :id => 0, :name => 1, :ascii_name => 2, :alternate_names => 3, :latitude => 4, :longitude => 5, :country => 8, :timezone => 17 }
- MAPPING =
ActiveSupport::TimeZone::MAPPING.each_with_object({}) do |field, mapping| mapping[field.last] = field.first end
Class Method Summary collapse
Class Method Details
.each ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/city_time_zone/seed_data.rb', line 22 def self.each # cities.txt is a city time zone data file from GeoNames (http://www.geonames.org/). File.open("data/cities.txt") do |f| f.each_line do |row| fields = row.split("\t") timezone = MAPPING[fields[FIELDS[:timezone]]] yield [fields[FIELDS[:ascii_name]], timezone] if timezone end end end |