Class: AtlasEngine::PostAddressImporter

Inherits:
Object
  • Object
show all
Defined in:
app/models/atlas_engine/post_address_importer.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ PostAddressImporter

Returns a new instance of PostAddressImporter.



8
9
10
# File 'app/models/atlas_engine/post_address_importer.rb', line 8

def initialize(file)
  @file = file
end

Instance Method Details

#importObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/atlas_engine/post_address_importer.rb', line 12

def import
  CSV.foreach(@file, headers: true) do |row|
    PostAddress.create!(
      source_id: row["source_id"],
      locale: row["locale"],
      country_code: row["country_code"],
      province_code: row["province_code"],
      region1: row["region1"],
      region2: row["region2"],
      region3: row["region3"],
      region4: row["region4"],
      city: row["city"],
      suburb: row["suburb"],
      zip: row["zip"],
      street: row["street"],
      building_name: row["building_name"],
      latitude: row["latitude"],
      longitude: row["longitude"],
    )
  end
end