Sha256: d6888cdb72040c9536fd14f55ce3ca90b90c3bf077931b5dca815526ae542b19
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 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
3 entries across 3 versions & 1 rubygems