Class: GovKit::FollowTheMoney::Contribution
- Inherits:
-
GovKit::FollowTheMoneyResource
- Object
- Resource
- GovKit::FollowTheMoneyResource
- GovKit::FollowTheMoney::Contribution
- Defined in:
- lib/gov_kit/follow_the_money.rb
Overview
Wrap contributions to a candidate. See the FollowTheMoney API.
Direct Known Subclasses
BusinessContribution, IndustryContribution, SectorContribution
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.find(nimsp_id) ⇒ Contribution
Return contributions to a candidate.
-
.top(nimsp_id) ⇒ [Contribution]
Return a list of the top contributors to a candidate.
Methods inherited from GovKit::FollowTheMoneyResource
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(nimsp_id) ⇒ Contribution
Return contributions to a candidate. See the FollowTheMoney API.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/gov_kit/follow_the_money.rb', line 92 def self.find(nimsp_id) next_page, result, page_num = "yes", [], 0 until next_page != "yes" doc = get_xml("/candidates.contributions.php", :query => {"imsp_candidate_id" => nimsp_id, :page => page_num}) next_page = doc.children.first.attributes['next_page'].value page_num += 1 result += doc.search('//contribution').collect { |x| x.attributes } end stringify_values_of(result) parse(result) end |
.top(nimsp_id) ⇒ [Contribution]
Return a list of the top contributors to a candidate. See the FollowTheMoney API.
114 115 116 117 118 119 120 |
# File 'lib/gov_kit/follow_the_money.rb', line 114 def self.top(nimsp_id) doc = get_xml("/candidates.top_contributor.php", :query => {"imsp_candidate_id" => nimsp_id}) result = doc.search('//top_contributor').collect { |x| x.attributes } stringify_values_of(result) parse(result) end |