Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add YARD doc comments to OpenCongressObject.

  • Loading branch information...
commit b8322a443dc8e979fc4275f66c19e17590010b44 1 parent 677d012
@jeff-r jeff-r authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/gov_kit/open_congress.rb
View
30 lib/gov_kit/open_congress.rb
@@ -12,6 +12,13 @@ module GovKit::OpenCongress
autoload :Person, 'gov_kit/open_congress/person'
autoload :PersonStat, 'gov_kit/open_congress/person_stat'
+ # Parent class for classes that wrap {http://www.opencongress.org/api OpenCongress data}.
+ #
+ # Unlike the wrapper classes for data from {FollowTheMoneyResource FollowTheMoney},
+ # {OpenStatesResource OpenStates}, {TransparencyDataResource TransparencyData},
+ # and {VoteSmartResource VoteSmart}, OpenCongressObject does not inherit
+ # from {GovKit::Resource}
+ #
class OpenCongressObject
def initialize(obj, params)
@@ -21,6 +28,8 @@ def initialize(obj, params)
end
end
+ # Create a query url, by adding the method path and query parameters to the
+ # base url of {http://www.opencongress.org/api}.
def self.construct_url(api_method, params)
url = nil
getkey = GovKit::configuration.opencongress_apikey.nil? ? "" : "&key=#{GovKit::configuration.opencongress_apikey}"
@@ -28,6 +37,10 @@ def self.construct_url(api_method, params)
return url
end
+ # Convert a hash to a string of query parameters.
+ #
+ # @param [Hash] h a hash.
+ # @return [String] a string of query parameters.
def self.hash2get(h)
get_string = ""
@@ -38,6 +51,17 @@ def self.hash2get(h)
get_string
end
+ # Iterates through the array returned by {make_call},
+ # converting each hash to an OpenCongressObject subclass.
+ #
+ # @param [Hash] results the array returned by make_call.
+ # @return a hash of arrays of OpenCongressObject objects, with these keys:
+ # * :also_supporting_bills
+ # * :also_opposing_bills
+ # * :also_disapproved_senators
+ # * :also_disapproved_representatives
+ # * :also_approved_senators
+ # * :also_approved_representatives
def self.parse_supporting_results(result)
working = result["opencongress_users_tracking"]
@@ -80,6 +104,12 @@ def self.parse_supporting_results(result)
end
+ # Get the data from {http://www.opencongress.org/api OpenCongress data}. Called by subclasses.
+ #
+ # Parses the data using {http://flori.github.com/json/doc/index.html JSON.parse}, which
+ # returns an array of hashes.
+ #
+ # @return the returned data, as an array of hashes.
def self.make_call(this_url)
result = nil
begin
Please sign in to comment.
Something went wrong with that request. Please try again.