Sha256: eb5cff72d246ef8ef2133725f5e8f523d633afae225b0d098b59a5b50b0c68c6
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module NYTimes module Congress class Congress < Base attr_reader :number, :chamber include AttributeTransformation def initialize(number, chamber) @number = integer_for number @chamber = symbol_for chamber raise AttributeError unless number && chamber end def members(params = {}) @members ||= fetch_members end def roll_call_vote(session_number, roll_call_number, params = {}) results = Base.invoke("#{api_path}/sessions/#{session_number}/votes/#{roll_call_number}.json")['results']['votes']['vote'] results.merge!({'chamber' => chamber}) # TODO 'chamber' is missing from RollCallVote JSON results for some reason RollCallVote.new(results) end def to_s "#{number} #{chamber.upcase}" end protected def fetch_members results = Base.invoke("#{api_path}/members.json")['results'].first results['members'].inject({}) do |hash, member| hash[member['id']] = Legislator.new(member) hash end end def api_path "#{number}/#{chamber}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hoverbird-ny-times-congress-1.0.0 | lib/ny-times/congress/congress.rb |
hoverbird-ny-times-congress-1.1.0 | lib/ny-times/congress/congress.rb |