module USGeo::Demographics

This module is mixed into all models. Note that the area given for land and water is in square miles.

Public Instance Methods

percent_land() click to toggle source

The fraction of the area that is composed of land instead of water.

# File lib/us_geo/demographics.rb, line 20
def percent_land
  land_area / total_area if land_area
end
population_density() click to toggle source

Population per square mile.

# File lib/us_geo/demographics.rb, line 10
def population_density
  population.to_f / land_area if population && land_area
end
total_area() click to toggle source

Total area of both land an water in square miles

# File lib/us_geo/demographics.rb, line 15
def total_area
  land_area.to_f + water_area.to_f if land_area
end