Class: CensusFor::State
- Inherits:
-
Object
- Object
- CensusFor::State
- Defined in:
- lib/census_for.rb
Class Method Summary collapse
Class Method Details
.population(request) ⇒ Object
93 94 95 96 |
# File 'lib/census_for.rb', line 93 def self.population(request) state = Abbrev.converter(request) return population_lookup(state) end |
.population_lookup(state) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/census_for.rb', line 98 def self.population_lookup(state) if state counties_in_state = [] CensusData.data.each do |x| counties_in_state << x if x[:"geo.display_label"].split(/\s*,\s*/).last == "#{state}" end counties_pop_total = 0 counties_in_state.each do |c| counties_pop_total += c[:respop72014] end return counties_pop_total else 'not found' end end |