Module: USGeo::Population

Overview

This module is mixed into all models with a population and land area.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#housing_unitsInteger?

Returns Total housing units in the area.

Returns:

  • (Integer, nil)

    Total housing units in the area.



# File 'lib/us_geo/population.rb', line 9

#populationInteger?

Returns Total population of the area.

Returns:

  • (Integer, nil)

    Total population of the area.



# File 'lib/us_geo/population.rb', line 6

Instance Method Details

#population_densityFloat?

Population per square mile.

Returns:

  • (Float, nil)


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_kmFloat?

Population per square kilometer.

Returns:

  • (Float, nil)


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