Module: USGeo::Demographics

Overview

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

Instance Method Summary collapse

Instance Method Details

#percent_landObject

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



20
21
22
# File 'lib/us_geo/demographics.rb', line 20

def percent_land
  land_area / total_area if land_area
end

#population_densityObject

Population per square mile.



10
11
12
# File 'lib/us_geo/demographics.rb', line 10

def population_density
  population.to_f / land_area if population && land_area
end

#total_areaObject

Total area of both land an water in square miles



15
16
17
# File 'lib/us_geo/demographics.rb', line 15

def total_area
  land_area.to_f + water_area.to_f if land_area
end