Class: GovTrack::Vote

Inherits:
Base show all
Defined in:
lib/govtrack/vote.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 = {}) ⇒ Vote

Returns a new instance of Vote.



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

def initialize(attributes={})
  super
  @created = DateTime.parse(@created) if @created
end

Class Method Details

.find(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/govtrack/vote.rb', line 9

def self.find(args)
  #API doesn't allow searching for bill by ID, so query with congress, bill_type, and number.
  if args[:related_bill]
    args[:related_bill__congress] = args[:related_bill].congress
    args[:related_bill__bill_type] = args[:related_bill].bill_type.to_bill_type_number
    args[:related_bill__number] = args[:related_bill].number
    args.delete(:related_bill)
  end
  
  super
end

Instance Method Details



21
22
23
# File 'lib/govtrack/vote.rb', line 21

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