Class: GovKit::OpenCongress::Bill

Inherits:
OpenCongressObject show all
Defined in:
lib/gov_kit/open_congress/bill.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenCongressObject

construct_url, hash2get, make_call, parse_supporting_results

Constructor Details

#initialize(params) ⇒ Bill

Returns a new instance of Bill.



6
7
8
# File 'lib/gov_kit/open_congress/bill.rb', line 6

def initialize(params)
  super Bill, params
end

Instance Attribute Details

#bill_titlesObject

Returns the value of attribute bill_titles.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def bill_titles
  @bill_titles
end

#bill_typeObject

Returns the value of attribute bill_type.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def bill_type
  @bill_type
end

#co_sponsorsObject

Returns the value of attribute co_sponsors.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def co_sponsors
  @co_sponsors
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def id
  @id
end

#identObject

Returns the value of attribute ident.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def ident
  @ident
end

#introducedObject

Returns the value of attribute introduced.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def introduced
  @introduced
end

#last_actionObject

Returns the value of attribute last_action.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def last_action
  @last_action
end

#last_speechObject

Returns the value of attribute last_speech.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def last_speech
  @last_speech
end

#last_vote_dateObject

Returns the value of attribute last_vote_date.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def last_vote_date
  @last_vote_date
end

#last_vote_rollObject

Returns the value of attribute last_vote_roll.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def last_vote_roll
  @last_vote_roll
end

#last_vote_whereObject

Returns the value of attribute last_vote_where.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def last_vote_where
  @last_vote_where
end

#most_recent_actionsObject

Returns the value of attribute most_recent_actions.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def most_recent_actions
  @most_recent_actions
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def number
  @number
end

#plain_language_summaryObject

Returns the value of attribute plain_language_summary.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def plain_language_summary
  @plain_language_summary
end

#recent_blogsObject

Returns the value of attribute recent_blogs.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def recent_blogs
  @recent_blogs
end

#recent_newsObject

Returns the value of attribute recent_news.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def recent_news
  @recent_news
end

#sessionObject

Returns the value of attribute session.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def session
  @session
end

Returns the value of attribute sponsor.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def sponsor
  @sponsor
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def status
  @status
end

#title_full_commonObject

Returns the value of attribute title_full_common.



4
5
6
# File 'lib/gov_kit/open_congress/bill.rb', line 4

def title_full_common
  @title_full_common
end

Class Method Details

.bills_in_the_news_this_weekObject



36
37
38
39
40
41
42
43
44
# File 'lib/gov_kit/open_congress/bill.rb', line 36

def self.bills_in_the_news_this_week
  url = construct_url("bills_in_the_news_this_week", {})
  if (result = make_call(url))
    bills = parse_results(result)
    return bills
  else
    nil
  end      
end

.find(params) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gov_kit/open_congress/bill.rb', line 14

def self.find(params)

  url = construct_url("bills", params)

  if (result = make_call(url))
    parse_results(result)
  else
    nil
  end

end

.find_by_idents(idents) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/gov_kit/open_congress/bill.rb', line 86

def self.find_by_idents(idents)
  q = []
  if idents.class.to_s == "Array"
    q = idents
  else
    q = idents.split(',')
  end

  url = Bill.construct_url("bills_by_ident", {:ident => q.join(',')})

  if (result = make_call(url))
    bills = parse_results(result)
  else
    nil
  end
end

.find_by_query(q) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/gov_kit/open_congress/bill.rb', line 76

def self.find_by_query(q)
  url = Bill.construct_url("bills_by_query", {:q => q})

  if (result = make_call(url))
    bills = parse_results(result)
  else
    nil
  end
end

.most_blogged_bills_this_weekObject



26
27
28
29
30
31
32
33
34
# File 'lib/gov_kit/open_congress/bill.rb', line 26

def self.most_blogged_bills_this_week
  url = construct_url("most_blogged_bills_this_week", {})
  if (result = make_call(url))
    bills = parse_results(result)
    return bills
  else
    nil
  end      
end

.most_opposed_bills_this_weekObject



66
67
68
69
70
71
72
73
74
# File 'lib/gov_kit/open_congress/bill.rb', line 66

def self.most_opposed_bills_this_week
  url = construct_url("most_opposed_bills_this_week", {})
  if (result = make_call(url))
    bills = parse_results(result)
    return bills
  else
    nil
  end      
end

.most_supported_bills_this_weekObject



56
57
58
59
60
61
62
63
64
# File 'lib/gov_kit/open_congress/bill.rb', line 56

def self.most_supported_bills_this_week
  url = construct_url("most_supported_bills_this_week", {})
  if (result = make_call(url))
    bills = parse_results(result)
    return bills
  else
    nil
  end      
end

.most_tracked_bills_this_weekObject



46
47
48
49
50
51
52
53
54
# File 'lib/gov_kit/open_congress/bill.rb', line 46

def self.most_tracked_bills_this_week
  url = construct_url("most_tracked_bills_this_week", {})
  if (result = make_call(url))
    bills = parse_results(result)
    return bills
  else
    nil
  end      
end

.parse_results(result) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/gov_kit/open_congress/bill.rb', line 123

def self.parse_results(result)

  bills = []
  result["bills"].each do |bill|
  
    these_recent_blogs = bill["recent_blogs"]
    blogs = []

    if these_recent_blogs
      these_recent_blogs.each do |trb|
        blogs << BlogPost.new(trb)
      end
    end

    bill["recent_blogs"] = blogs


    these_recent_news = bill["recent_news"]
    news = []
    if these_recent_news
      these_recent_news.each do |trb|
        news << NewsPost.new(trb)
      end
    end

    bill["recent_news"] = news

    these_co_sponsors = bill["co_sponsors"]
    co_sponsors = []
    if these_co_sponsors
      these_co_sponsors.each do |tcs|
        co_sponsors << Person.new(tcs)
      end
    end

    bill["co_sponsors"] = co_sponsors

  
    bill["sponsor"] = Person.new(bill["sponsor"]) if bill["sponsor"]
  
  
    bills << Bill.new(bill)
  end
  bills
end

Instance Method Details

#opencongress_users_opposing_bill_are_alsoObject



113
114
115
116
117
118
119
120
121
# File 'lib/gov_kit/open_congress/bill.rb', line 113

def opencongress_users_opposing_bill_are_also
  url = Bill.construct_url("opencongress_users_opposing_bill_are_also/#{ident}", {})
  if (result = Bill.make_call(url))
    bills = Bill.parse_supporting_results(result)
    return bills
  else
    nil
  end
end

#opencongress_users_supporting_bill_are_alsoObject



103
104
105
106
107
108
109
110
111
# File 'lib/gov_kit/open_congress/bill.rb', line 103

def opencongress_users_supporting_bill_are_also
  url = Bill.construct_url("opencongress_users_supporting_bill_are_also/#{ident}", {})
  if (result = Bill.make_call(url))
    bills = Bill.parse_supporting_results(result)
    return bills
  else
    nil
  end
end