Module: USGeo::Population
- Included in:
- CombinedStatisticalArea, CoreBasedStatisticalArea, County, CountySubdivision, Division, MetropolitanDivision, Place, Region, State, UrbanArea, Zcta
- Defined in:
- lib/us_geo/population.rb
Overview
This module is mixed into all models with a population and land area.
Instance Attribute Summary collapse
-
#housing_units ⇒ Integer?
Total housing units in the area.
-
#population ⇒ Integer?
Total population of the area.
Instance Method Summary collapse
-
#housing_density ⇒ Float?
Housing units per square mile.
-
#housing_density_km ⇒ Float?
Housing units per square kilometer.
-
#population_density ⇒ Float?
Population per square mile.
-
#population_density_km ⇒ Float?
Population per square kilometer.
Instance Attribute Details
#housing_units ⇒ Integer?
Returns Total housing units in the area.
|
|
# File 'lib/us_geo/population.rb', line 9
|
#population ⇒ Integer?
Returns Total population of the area.
|
|
# File 'lib/us_geo/population.rb', line 6
|
Instance Method Details
#housing_density ⇒ Float?
Housing units per square mile.
29 30 31 |
# File 'lib/us_geo/population.rb', line 29 def housing_density housing_units.to_f / land_area if housing_units && land_area.to_f > 0 end |
#housing_density_km ⇒ Float?
Housing units per square kilometer.
36 37 38 |
# File 'lib/us_geo/population.rb', line 36 def housing_density_km housing_units.to_f / land_area_km if housing_units && land_area.to_f > 0 end |
#population_density ⇒ Float?
Population per square mile.
15 16 17 |
# File 'lib/us_geo/population.rb', line 15 def population_density population.to_f / land_area if population && land_area.to_f > 0 end |
#population_density_km ⇒ Float?
Population per square kilometer.
22 23 24 |
# File 'lib/us_geo/population.rb', line 22 def population_density_km population.to_f / land_area_km if population && land_area.to_f > 0 end |