Class: CivicAide::Elections

Inherits:
Object
  • Object
show all
Defined in:
lib/civic_aide/elections.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, election_id = nil) ⇒ Elections

Returns a new instance of Elections.



5
6
7
8
# File 'lib/civic_aide/elections.rb', line 5

def initialize(client, election_id=nil)
  @client = client
  @election_id = election_id
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/civic_aide/elections.rb', line 3

def client
  @client
end

#election_idObject (readonly)

Returns the value of attribute election_id.



3
4
5
# File 'lib/civic_aide/elections.rb', line 3

def election_id
  @election_id
end

Instance Method Details

#allObject



10
11
12
13
# File 'lib/civic_aide/elections.rb', line 10

def all
  response = client.get('/elections')
  response.except!(:kind)
end

#at(address) ⇒ Object

Raises:



15
16
17
18
19
# File 'lib/civic_aide/elections.rb', line 15

def at(address)
  raise ElectionIdMissing, "Missing a required election id" if @election_id.nil?
  response = client.post("/voterinfo/#{election_id}/lookup", {officialOnly: @client.official_only}, {address: address})
  response.except!(:kind, :status)
end