Class: GovKit::VoteSmart::State

Inherits:
GovKit::VoteSmartResource show all
Defined in:
lib/gov_kit/vote_smart.rb

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #raw_response

Class Method Summary collapse

Methods inherited from Resource

#initialize, instantiate, instantiate_collection, parse, #to_md5, #unload

Constructor Details

This class inherits a constructor from GovKit::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GovKit::Resource

Class Method Details

.find_allObject



9
10
11
12
# File 'lib/gov_kit/vote_smart.rb', line 9

def self.find_all
  response = get("/State.getStateIDs")
  parse(response['stateList']['list']['state'])
end

.find_cities(stateId) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/gov_kit/vote_smart.rb', line 25

def self.find_cities(stateId)
  response = get("/Local.getCities", :query => {"stateId" => stateId})
  return [] if !response['cities']
  
  if response['cities']['city'].instance_of?(Array)
    parse(response['cities']['city'])
  else
    [ parse(response['cities']['city']) ]         
  end
end

.find_counties(stateId) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/gov_kit/vote_smart.rb', line 14

def self.find_counties(stateId)
  response = get("/Local.getCounties", :query => {"stateId" => stateId})
  return [] if !response['counties']

  if response['counties']['county'].instance_of?(Array)
    parse(response['counties']['county'])
  else
    [ parse(response['counties']['county']) ]         
  end
end