Class: USGeo::Region

Inherits:
BaseRecord
  • Object
show all
Includes:
Area, Population
Defined in:
lib/us_geo/region.rb

Overview

U.S. region.

Constant Summary

Constants inherited from BaseRecord

BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED

Instance Attribute Summary collapse

Attributes included from Area

#land_area, #water_area

Attributes included from Population

#housing_units, #population

Attributes inherited from BaseRecord

#status, #updated_at

Class Method Summary collapse

Methods included from Area

#land_area_km, #percent_land, #total_area, #water_area_km

Methods included from Population

#housing_density, #housing_density_km, #population_density, #population_density_km

Methods inherited from BaseRecord

#imported?, #manual?, #removed?

Instance Attribute Details

#idInteger

Returns ID of the region.

Returns:

  • (Integer)

    ID of the region.



# File 'lib/us_geo/region.rb', line 14

Class Method Details

.load!(uri = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/us_geo/region.rb', line 21

def load!(uri = nil)
  location = data_uri(uri || "regions.csv")

  import! do
    load_data_file(location) do |row|
      load_record!(id: row["ID"]) do |record|
        record.name = row["Name"]
        record.population = row["Population"]
        record.housing_units = row["Housing Units"]
        record.land_area = row["Land Area"]
        record.water_area = row["Water Area"]
      end
    end
  end
end