u_s_census 0.0.2 → 0.0.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
1
  ## v0.0.1
2
2
 
3
3
  * initial release
4
+
5
+ ## v0.0.3
6
+
7
+ * clean up
@@ -1,3 +1,3 @@
1
1
  module USCensus
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/u_s_census.rb CHANGED
@@ -11,14 +11,35 @@ module USCensus
11
11
  }
12
12
 
13
13
  # Get 2010 Census SF1 data for the states by using
14
- # <tt>census_summary_2010</tt> and pass it key and list of states (FIPS codes).
14
+ # <tt>census_summary_2010</tt> and pass it key, list of states (FIPS codes or
15
+ # state names) and api_variables
16
+ # (http://www.census.gov/developers/data/sf1.xml).
15
17
  # This will return array of hashes.
16
- def self.census_summary_2010(key, states = "*")
18
+ #
19
+ # <tt>USCensus::census_summary_2010(key, ["California"], ["P0010001"])</tt>
20
+ #
21
+ def self.census_summary_2010(key, states = "*", api_variables = ["P0010001"])
17
22
  states = fips_codes(states)
18
- url = HOST + "sf1?key=#{key}&get=P0010001,NAME&for=state:#{states}"
23
+ api_variables = api_variables.join(',')
24
+ url = HOST + "sf1?key=#{key}&get=#{api_variables},NAME&for=state:#{states}"
19
25
  output = open(url)
20
26
  return parse(output, key)
21
27
  end
28
+ # Get ACS 2010 5 year data for for the states
29
+ # <tt>census_acs_2010</tt> and pass it key, list of states (FIPS codes or
30
+ # state names) and api_variables
31
+ # (http://www.census.gov/developers/data/2010acs5_variables.xml).
32
+ # This will return array of hashes.
33
+ #
34
+ # <tt>USCensus::census_acs_2010(key, ["California"], ["B02001_001E"])</tt>
35
+ #
36
+ def self.census_acs_2010(key, states = "*", api_variables = ["B02001_001E"])
37
+ states = fips_codes(states)
38
+ api_variables = api_variables.join(',')
39
+ url = HOST + "acs5?key=#{key}&get=B02001_001E,NAME&for=state:#{states}"
40
+ output = open(url)
41
+ return parse(output,key)
42
+ end
22
43
  private
23
44
  def self.fips_codes(states)
24
45
  if states.is_a? Array
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u_s_census
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: