Class: VoteSmart::Candidate
- Defined in:
- lib/vote_smart/candidate.rb
Class Method Summary collapse
-
.get_by_district(district_id, election_year = nil) ⇒ Object
Returns candidates in the provided district_id.
-
.get_by_election(election_id) ⇒ Object
Returns candidates in the provided election_id.
-
.get_by_lastname(last_name, election_year = nil) ⇒ Object
Searches for candidates with exact lastname matches.
-
.get_by_levenstein(last_name, election_year = nil) ⇒ Object
Searches for candidates with fuzzy lastname match.
-
.get_by_office_state(office_id, state_id = "NA", election_year = nil) ⇒ Object
Returns a list of candidates/incumbents that fit the criteria.
-
.get_by_zip(zip5, election_year = nil, zip4 = nil, stage_id = nil) ⇒ Object
Returns candidates in the provided zip code, with optional zip+4 and stage.
Methods inherited from Common
construct_url, get_json_data, hash2get, #initialize, parallelize!, request, response_child, session, set_attribute_map, #update_attributes
Constructor Details
This class inherits a constructor from VoteSmart::Common
Class Method Details
.get_by_district(district_id, election_year = nil) ⇒ Object
Returns candidates in the provided district_id
26 27 28 |
# File 'lib/vote_smart/candidate.rb', line 26 def self.get_by_district district_id, election_year = nil request("Candidates.getByDistrict", "districtId" => district_id, "electionYear" => election_year) end |
.get_by_election(election_id) ⇒ Object
Returns candidates in the provided election_id
21 22 23 |
# File 'lib/vote_smart/candidate.rb', line 21 def self.get_by_election election_id request("Candidates.getByElection", "electionId" => election_id) end |
.get_by_lastname(last_name, election_year = nil) ⇒ Object
Searches for candidates with exact lastname matches
11 12 13 |
# File 'lib/vote_smart/candidate.rb', line 11 def self.get_by_lastname last_name, election_year = nil request("Candidates.getByLastname", "lastName" => last_name, "electionYear" => election_year) end |
.get_by_levenstein(last_name, election_year = nil) ⇒ Object
Searches for candidates with fuzzy lastname match
16 17 18 |
# File 'lib/vote_smart/candidate.rb', line 16 def self.get_by_levenstein last_name, election_year = nil request("Candidates.getByLevenstein", "lastName" => last_name, "electionYear" => election_year) end |
.get_by_office_state(office_id, state_id = "NA", election_year = nil) ⇒ Object
Returns a list of candidates/incumbents that fit the criteria
6 7 8 |
# File 'lib/vote_smart/candidate.rb', line 6 def self.get_by_office_state office_id, state_id = "NA", election_year = nil request("Candidates.getByOfficeState", "officeId" => office_id, "stateId" => state_id, "electionYear" => election_year) end |
.get_by_zip(zip5, election_year = nil, zip4 = nil, stage_id = nil) ⇒ Object
Returns candidates in the provided zip code, with optional zip+4 and stage
31 32 33 |
# File 'lib/vote_smart/candidate.rb', line 31 def self.get_by_zip zip5, election_year=nil, zip4=nil, stage_id=nil request("Candidates.getByZip", "zip5" => zip5, "electionYear" => election_year, "zip4" => zip4, "stageId" => stage_id) end |