Class: Concensus::State

Inherits:
Resource show all
Defined in:
lib/concensus/state.rb

Instance Attribute Summary

Attributes inherited from Resource

#geometry, #name, #state, #year

Class Method Summary collapse

Methods inherited from Resource

already_unzipped?, file_extension, filename_without_extension, get_and_unzip, #initialize, process_find, state_code_to_id

Constructor Details

This class inherits a constructor from Concensus::Resource

Class Method Details

.find(state) ⇒ Concensus::Resource

Returns matched state.

Returns:


5
6
7
8
9
10
11
12
13
14
# File 'lib/concensus/state.rb', line 5

def self.find(state)
  
  if Concensus::configuration.year == 2010
    shp_file_path = get_and_unzip("STATE/2010/tl_2010_#{state_code_to_id(state)}_state10.zip")
    return process_find("State", shp_file_path, "NAME10", state)[0]  
  else
    raise NoResourceForYear
  end
      
end

.find_allArray

Returns all states.

Returns:

  • (Array)

    all states


17
18
19
20
21
22
23
# File 'lib/concensus/state.rb', line 17

def self.find_all
  shapes = []
  Concensus::configuration.census_state_ids.each do |state_code, _|
    shapes << find(state_code)
  end
  return shapes
end