Class: GovKit::VoteSmart::Official
- Inherits:
-
GovKit::VoteSmartResource
- Object
- Resource
- GovKit::VoteSmartResource
- GovKit::VoteSmart::Official
- Defined in:
- lib/gov_kit/vote_smart.rb
Instance Attribute Summary
Attributes inherited from Resource
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_all(stateOrLocalId) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gov_kit/vote_smart.rb', line 38 def self.find_all(stateOrLocalId) if stateOrLocalId.match(/[A-Za-z]/) # We're looking for state officals response = get("/Officials.getStatewide", :query => {"stateId" => stateOrLocalId}) else # We're looking for local officials response = get("/Local.getOfficials", :query => {"localId" => stateOrLocalId}) end return [] if !response['candidateList'] if response['candidateList']['candidate'].instance_of?(Array) parse(response['candidateList']['candidate']) else [ parse(response['candidateList']['candidate']) ] end end |
.find_by_office_state(officeId, stateId = 'NA') ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/gov_kit/vote_smart.rb', line 54 def self.find_by_office_state(officeId, stateId = 'NA') response = get("/Officials.getByOfficeState", :query => { "officeId" => officeId, "stateId" => stateId }) return [] if !response['candidateList'] if response['candidateList']['candidate'].instance_of?(Array) parse(response['candidateList']['candidate']) else [ parse(response['candidateList']['candidate']) ] end end |