Class: GovKit::VoteSmart::Bio

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(candidate_id) ⇒ Object

Raises:



23
24
25
26
27
28
29
30
# File 'lib/gov_kit/vote_smart.rb', line 23

def self.find(candidate_id)
  response = get("/CandidateBio.getBio", :query => {"candidateId" => candidate_id})

  # Sometimes VoteSmart returns nil if no one is found!
  raise(ResourceNotFound, 'Could not find bio for candidate') if response.blank? || response['error']

  parse(response['bio']['candidate'])
end