census_data 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/census_data.gemspec +1 -1
- data/examples/pull_data_by_zipcode.rb +1 -1
- data/lib/census_data.rb +6 -5
- metadata +2 -2
- data/census_data-0.1.0.gem +0 -0
data/.gitignore
ADDED
data/census_data.gemspec
CHANGED
data/lib/census_data.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
class CensusData
|
2
2
|
|
3
|
-
def self.
|
3
|
+
def self.income_by_zipcode(zip_code)
|
4
4
|
county_name = ''
|
5
5
|
county_code = ''
|
6
|
-
median_income =
|
6
|
+
median_income = 0
|
7
|
+
per_capita_income = 0
|
7
8
|
|
8
9
|
path = File.expand_path(File.dirname(__FILE__)) + '/../data/county_names_by_zip.txt'
|
9
10
|
CSV.foreach(path, {:headers => true}) do |row|
|
@@ -25,13 +26,13 @@ class CensusData
|
|
25
26
|
path = File.expand_path(File.dirname(__FILE__)) + '/../data/IncomeDataSet.txt'
|
26
27
|
CSV.foreach(path, {:headers => true}) do |row|
|
27
28
|
if row[0] == county_code
|
28
|
-
median_income = row[32]
|
29
|
+
median_income = row[32].to_i
|
30
|
+
per_capita_income = row[33].to_i
|
29
31
|
break
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
{:median_income => median_income, :per_capita_income => per_capita_income}
|
35
36
|
end
|
36
37
|
|
37
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: census_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -18,10 +18,10 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- .gitignore
|
21
22
|
- Gemfile
|
22
23
|
- Gemfile.lock
|
23
24
|
- Rakefile
|
24
|
-
- census_data-0.1.0.gem
|
25
25
|
- census_data.gemspec
|
26
26
|
- data/.DS_Store
|
27
27
|
- data/DataDict.txt
|
data/census_data-0.1.0.gem
DELETED
Binary file
|