Class: OpenCongress::OCBill
- Inherits:
-
OpenCongressObject
- Object
- OpenCongressObject
- OpenCongress::OCBill
- Defined in:
- lib/opencongress/bill.rb
Instance Attribute Summary collapse
-
#bill_titles ⇒ Object
Returns the value of attribute bill_titles.
-
#bill_type ⇒ Object
Returns the value of attribute bill_type.
-
#co_sponsors ⇒ Object
Returns the value of attribute co_sponsors.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ident ⇒ Object
Returns the value of attribute ident.
-
#introduced ⇒ Object
Returns the value of attribute introduced.
-
#last_action ⇒ Object
Returns the value of attribute last_action.
-
#last_speech ⇒ Object
Returns the value of attribute last_speech.
-
#last_vote_date ⇒ Object
Returns the value of attribute last_vote_date.
-
#last_vote_roll ⇒ Object
Returns the value of attribute last_vote_roll.
-
#last_vote_where ⇒ Object
Returns the value of attribute last_vote_where.
-
#most_recent_actions ⇒ Object
Returns the value of attribute most_recent_actions.
-
#number ⇒ Object
Returns the value of attribute number.
-
#plain_language_summary ⇒ Object
Returns the value of attribute plain_language_summary.
-
#recent_blogs ⇒ Object
Returns the value of attribute recent_blogs.
-
#recent_news ⇒ Object
Returns the value of attribute recent_news.
-
#session ⇒ Object
Returns the value of attribute session.
-
#sponsor ⇒ Object
Returns the value of attribute sponsor.
-
#status ⇒ Object
Returns the value of attribute status.
-
#title_full_common ⇒ Object
Returns the value of attribute title_full_common.
Class Method Summary collapse
- .all_where(params) ⇒ Object
- .bills_in_the_news_this_week ⇒ Object
- .by_idents(idents) ⇒ Object
- .by_query(q) ⇒ Object
- .most_blogged_bills_this_week ⇒ Object
- .most_opposed_bills_this_week ⇒ Object
- .most_supported_bills_this_week ⇒ Object
- .most_tracked_bills_this_week ⇒ Object
- .parse_results(result) ⇒ Object
Instance Method Summary collapse
-
#initialize(params) ⇒ OCBill
constructor
A new instance of OCBill.
- #opencongress_users_opposing_bill_are_also ⇒ Object
- #opencongress_users_supporting_bill_are_also ⇒ Object
Methods inherited from OpenCongressObject
construct_url, hash2get, make_call, parse_supporting_results
Constructor Details
#initialize(params) ⇒ OCBill
Returns a new instance of OCBill.
10 11 12 13 14 |
# File 'lib/opencongress/bill.rb', line 10 def initialize(params) params.each do |key, value| instance_variable_set("@#{key}", value) if OCBill.instance_methods.include? key end end |
Instance Attribute Details
#bill_titles ⇒ Object
Returns the value of attribute bill_titles.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def bill_titles @bill_titles end |
#bill_type ⇒ Object
Returns the value of attribute bill_type.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def bill_type @bill_type end |
#co_sponsors ⇒ Object
Returns the value of attribute co_sponsors.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def co_sponsors @co_sponsors end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def id @id end |
#ident ⇒ Object
Returns the value of attribute ident.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def ident @ident end |
#introduced ⇒ Object
Returns the value of attribute introduced.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def introduced @introduced end |
#last_action ⇒ Object
Returns the value of attribute last_action.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def last_action @last_action end |
#last_speech ⇒ Object
Returns the value of attribute last_speech.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def last_speech @last_speech end |
#last_vote_date ⇒ Object
Returns the value of attribute last_vote_date.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def last_vote_date @last_vote_date end |
#last_vote_roll ⇒ Object
Returns the value of attribute last_vote_roll.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def last_vote_roll @last_vote_roll end |
#last_vote_where ⇒ Object
Returns the value of attribute last_vote_where.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def last_vote_where @last_vote_where end |
#most_recent_actions ⇒ Object
Returns the value of attribute most_recent_actions.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def most_recent_actions @most_recent_actions end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def number @number end |
#plain_language_summary ⇒ Object
Returns the value of attribute plain_language_summary.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def plain_language_summary @plain_language_summary end |
#recent_blogs ⇒ Object
Returns the value of attribute recent_blogs.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def recent_blogs @recent_blogs end |
#recent_news ⇒ Object
Returns the value of attribute recent_news.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def recent_news @recent_news end |
#session ⇒ Object
Returns the value of attribute session.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def session @session end |
#sponsor ⇒ Object
Returns the value of attribute sponsor.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def sponsor @sponsor end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def status @status end |
#title_full_common ⇒ Object
Returns the value of attribute title_full_common.
6 7 8 |
# File 'lib/opencongress/bill.rb', line 6 def title_full_common @title_full_common end |
Class Method Details
.all_where(params) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/opencongress/bill.rb', line 20 def self.all_where(params) url = construct_url("bills", params) if (result = make_call(url)) bills = parse_results(result) else nil end end |
.bills_in_the_news_this_week ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/opencongress/bill.rb', line 42 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 |
.by_idents(idents) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/opencongress/bill.rb', line 92 def self.by_idents(idents) q = [] if idents.class.to_s == "Array" q = idents else q = idents.split(',') end url = OCBill.construct_url("bills_by_ident", {:ident => q.join(',')}) if (result = make_call(url)) bills = parse_results(result) else nil end end |
.by_query(q) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/opencongress/bill.rb', line 82 def self.by_query(q) url = OCBill.construct_url("bills_by_query", {:q => q}) if (result = make_call(url)) bills = parse_results(result) else nil end end |
.most_blogged_bills_this_week ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/opencongress/bill.rb', line 32 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_week ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/opencongress/bill.rb', line 72 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_week ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/opencongress/bill.rb', line 62 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_week ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/opencongress/bill.rb', line 52 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
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 168 169 170 171 172 173 |
# File 'lib/opencongress/bill.rb', line 129 def self.parse_results(result) bills = [] result.each do |bill| these_recent_blogs = bill["recent_blogs"] blogs = [] if these_recent_blogs these_recent_blogs.each do |trb| blogs << OCBlogPost.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 << OCNewsPost.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 << OCPerson.new(tcs) end end bill["co_sponsors"] = co_sponsors bill["sponsor"] = OCPerson.new(bill["sponsor"]) if bill["sponsor"] bills << OCBill.new(bill) end bills end |
Instance Method Details
#opencongress_users_opposing_bill_are_also ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'lib/opencongress/bill.rb', line 119 def opencongress_users_opposing_bill_are_also url = OCBill.construct_url("opencongress_users_opposing_bill_are_also/#{ident}", {}) if (result = OCBill.make_call(url)) bills = OCBill.parse_supporting_results(result) return bills else nil end end |
#opencongress_users_supporting_bill_are_also ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/opencongress/bill.rb', line 109 def opencongress_users_supporting_bill_are_also url = OCBill.construct_url("opencongress_users_supporting_bill_are_also/#{ident}", {}) if (result = OCBill.make_call(url)) bills = OCBill.parse_supporting_results(result) return bills else nil end end |