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 ADDED
@@ -0,0 +1,8 @@
1
+ .DS_Store
2
+ storage/*
3
+ doc/*
4
+ *.gem
5
+ bin/
6
+ .bundle/
7
+ .rbenv-version
8
+ index.rb
data/census_data.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  PROJECT_GEM = 'census_data'
3
- PROJECT_GEM_VERSION = '0.2.0'
3
+ PROJECT_GEM_VERSION = '0.2.1'
4
4
 
5
5
  s.name = PROJECT_GEM
6
6
  s.version = PROJECT_GEM_VERSION
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__)) + "/../lib/census_data.rb"
2
2
  require 'csv'
3
3
 
4
- CensusData.per_capita_income_by_zipcode(89506)
4
+ puts CensusData.income_by_zipcode(89506)
5
5
 
data/lib/census_data.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  class CensusData
2
2
 
3
- def self.per_capita_income_by_zipcode(zip_code)
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
- print "#{county_name} County, County Code #{county_code}, Median Income: #{median_income}"
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.0
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
Binary file