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



66
67
68
69
# File 'lib/gov_kit/vote_smart.rb', line 66

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



90
91
92
# File 'lib/gov_kit/vote_smart.rb', line 90

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:



83
84
85
86
87
88
# File 'lib/gov_kit/vote_smart.rb', line 83

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:



71
72
73
74
75
76
# File 'lib/gov_kit/vote_smart.rb', line 71

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



78
79
80
81
# File 'lib/gov_kit/vote_smart.rb', line 78

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