Class: VoteSmart::State

Inherits:
Common
  • Object
show all
Defined in:
lib/vote_smart/state.rb

Instance Attribute Summary collapse

Class Method Summary collapse

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/vote_smart/state.rb', line 5

def id
  @id
end

#largest_cityObject

Returns the value of attribute largest_city.



5
6
7
# File 'lib/vote_smart/state.rb', line 5

def largest_city
  @largest_city
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/vote_smart/state.rb', line 5

def name
  @name
end

Class Method Details

.allObject



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

def self.all
  response_child(get_state_ids, "stateList", "list", "state").collect {|attributes| State.new(attributes)}
end

.find_by_id(state_id) ⇒ Object



13
14
15
16
# File 'lib/vote_smart/state.rb', line 13

def self.find_by_id state_id
  response = response_child(get_state(state_id), "state", "details")
  State.new(response) unless response.empty?
end

.get_state(state_id) ⇒ Object

Returns detailed state information



24
25
26
# File 'lib/vote_smart/state.rb', line 24

def self.get_state state_id
  request("State.getState", "stateId" => state_id)
end

.get_state_idsObject

Returns a list of states and their 2 digit IDs



19
20
21
# File 'lib/vote_smart/state.rb', line 19

def self.get_state_ids
  request("State.getStateIDs")
end