Class: USGeo::UrbanArea
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- USGeo::UrbanArea
- Includes:
- Area, Population
- Defined in:
- lib/us_geo/urban_area.rb
Overview
Urban areas are split into either urbanized areas (population > 50,000) or urban cluster (population < 50,000).
Direct Known Subclasses
Constant Summary
Constants inherited from BaseRecord
BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED
Instance Attribute Summary
Attributes included from Population
Attributes included from Area
Attributes inherited from BaseRecord
Class Method Summary collapse
Instance Method Summary collapse
-
#cluster? ⇒ Boolean
Return true if the population is less than 50,000.
-
#urbanized? ⇒ Boolean
Return true if the population is greater than or equal to 50,000.
Methods included from Population
#housing_density, #housing_density_km, #population_density, #population_density_km
Methods included from Area
#land_area_km, #percent_land, #total_area, #water_area_km
Methods inherited from BaseRecord
#imported?, #manual?, #removed?
Class Method Details
.load!(uri = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/us_geo/urban_area.rb', line 66 def load!(uri = nil) location = data_uri(uri || "urban_areas.csv") import! do load_data_file(location) do |row| load_record!(geoid: row["GEOID"]) do |record| record.type = ((row["Population"].to_i >= 50_000) ? "UrbanizedArea" : "UrbanCluster") record.name = row["Name"] record.short_name = row["Short Name"] record.primary_county_geoid = row["Primary County GEOID"] record.population = row["Population"] record.housing_units = row["Housing Units"] record.land_area = row["Land Area"] record.water_area = row["Water Area"] record.lat = row["Latitude"] record.lng = row["Longitude"] end end end end |
Instance Method Details
#cluster? ⇒ Boolean
Return true if the population is less than 50,000.
98 99 100 |
# File 'lib/us_geo/urban_area.rb', line 98 def cluster? population < 50_000 end |
#urbanized? ⇒ Boolean
Return true if the population is greater than or equal to 50,000.
91 92 93 |
# File 'lib/us_geo/urban_area.rb', line 91 def urbanized? population >= 50_000 end |