Class: GovKit::VoteSmart::Bill

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



141
142
143
144
# File 'lib/gov_kit/vote_smart.rb', line 141

def self.find(bill_id)
  response = get('/Votes.getBill', :query => {'billId' => bill_id})
  parse(response['bill'])
end

.find_by_category_and_year(category_id, year) ⇒ Object



165
166
167
# File 'lib/gov_kit/vote_smart.rb', line 165

def self.find_by_category_and_year(category_id, year)
  find_by_category_and_year_and_state(category_id, year)
end

.find_by_category_and_year_and_state(category_id, year, state_abbrev = nil) ⇒ Object

Raises:



158
159
160
161
162
163
# File 'lib/gov_kit/vote_smart.rb', line 158

def self.find_by_category_and_year_and_state(category_id, year, state_abbrev = nil)
  response = get('/Votes.getBillsByCategoryYearState', :query => {'stateId' => state_abbrev, 'year' => year, 'categoryId' => category_id})
  raise(ResourceNotFound, response['error']['errorMessage']) if response['error'] && response['error']['errorMessage'] == 'No bills for this state, category, and year.'

  parse(response['bills'])
end

.find_by_year_and_state(year, state_abbrev) ⇒ Object

Raises:



146
147
148
149
150
151
# File 'lib/gov_kit/vote_smart.rb', line 146

def self.find_by_year_and_state(year, state_abbrev)
  response = get('/Votes.getBillsByYearState', :query => {'year' => year, 'stateId' => state_abbrev})
  raise(ResourceNotFound, response['error']['errorMessage']) if response['error'] && response['error']['errorMessage'] == 'No bills for this state and year.'

  parse(response['bills'])
end

.find_recent_by_state(state_abbrev) ⇒ Object



153
154
155
156
# File 'lib/gov_kit/vote_smart.rb', line 153

def self.find_recent_by_state(state_abbrev)
  response = get('/Votes.getBillsByStateRecent', :query => {'stateId' => state_abbrev})
  parse(response['bills'])
end