Class: GovTrack::Bill

Inherits:
Base show all
Defined in:
lib/govtrack/bill.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #eql?, find_by_id, find_by_uri, method_missing

Constructor Details

#initialize(attributes = {}) ⇒ Bill

Returns a new instance of Bill.



4
5
6
7
8
# File 'lib/govtrack/bill.rb', line 4

def initialize(attributes={})
  super
  @introduced_date = Date.parse(@introduced_date) if @introduced_date
  @current_status_date = Date.parse(@current_status_date) if @current_status_date
end

Class Method Details

.find(args) ⇒ Object



10
11
12
13
14
# File 'lib/govtrack/bill.rb', line 10

def self.find(args)
  args[:bill_type] = args[:bill_type].to_bill_type_number if args[:bill_type]
  args[:current_status] = args[:current_status].to_current_status_number if args[:current_status]
  super
end

Instance Method Details

#cosponsorsObject



20
21
22
23
24
25
26
27
28
# File 'lib/govtrack/bill.rb', line 20

def cosponsors
  if @cosponsors[0].class == GovTrack::Person 
    @cosponsors
  else
    @cosponsors.map! { |cosponsor_uri|
      GovTrack::Person.find_by_uri(cosponsor_uri)
    }
  end
end


16
17
18
# File 'lib/govtrack/bill.rb', line 16

def sponsor
  @sponsor.class == GovTrack::Person ? @sponsor : @sponsor = GovTrack::Person.find_by_id(@sponsor['id'])
end