Class: Geonames::Export
- Inherits:
-
Object
- Object
- Geonames::Export
- Defined in:
- lib/geonames_local/data/export.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ Export
constructor
A new instance of Export.
- #to_csv ⇒ Object
Constructor Details
#initialize(data) ⇒ Export
Returns a new instance of Export.
5 6 7 8 |
# File 'lib/geonames_local/data/export.rb', line 5 def initialize(data) info 'Starting export..' @data = data end |
Instance Method Details
#to_csv ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/geonames_local/data/export.rb', line 10 def to_csv file = 'export.csv' info "Writing #{file} (#{@data.length} objects)" CSV.open('export.csv', 'w') do |csv| csv << @data[0].export_header @data.each { |o| csv << o.export } end info 'Export done.' end |