Class: OpenCongress::OCBill

Inherits:
OpenCongressObject show all
Defined in:
lib/opencongress/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) ⇒ 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_titlesObject

Returns the value of attribute bill_titles.



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

def bill_titles
  @bill_titles
end

#bill_typeObject

Returns the value of attribute bill_type.



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

def bill_type
  @bill_type
end

#co_sponsorsObject

Returns the value of attribute co_sponsors.



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

def co_sponsors
  @co_sponsors
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#identObject

Returns the value of attribute ident.



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

def ident
  @ident
end

#introducedObject

Returns the value of attribute introduced.



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

def introduced
  @introduced
end

#last_actionObject

Returns the value of attribute last_action.



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

def last_action
  @last_action
end

#last_speechObject

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_dateObject

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_rollObject

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_whereObject

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_actionsObject

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

#numberObject

Returns the value of attribute number.



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

def number
  @number
end

#plain_language_summaryObject

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_blogsObject

Returns the value of attribute recent_blogs.



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

def recent_blogs
  @recent_blogs
end

#recent_newsObject

Returns the value of attribute recent_news.



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

def recent_news
  @recent_news
end

#sessionObject

Returns the value of attribute session.



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

def session
  @session
end

Returns the value of attribute sponsor.



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

def sponsor
  @sponsor
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#title_full_commonObject

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_weekObject



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_weekObject



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_weekObject



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_weekObject



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_weekObject



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_alsoObject



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_alsoObject



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