Class: OpenCongress::OCVotingComparison
- Inherits:
-
OpenCongressObject
- Object
- OpenCongressObject
- OpenCongress::OCVotingComparison
- Defined in:
- lib/opencongress/voting_comparison.rb
Instance Attribute Summary collapse
-
#hot_votes ⇒ Object
Returns the value of attribute hot_votes.
-
#other_votes ⇒ Object
Returns the value of attribute other_votes.
-
#percentage ⇒ Object
Returns the value of attribute percentage.
-
#person1 ⇒ Object
Returns the value of attribute person1.
-
#person2 ⇒ Object
Returns the value of attribute person2.
-
#same_vote ⇒ Object
Returns the value of attribute same_vote.
-
#shared_committees ⇒ Object
Returns the value of attribute shared_committees.
-
#total_votes ⇒ Object
Returns the value of attribute total_votes.
Instance Method Summary collapse
-
#initialize(params) ⇒ OCVotingComparison
constructor
A new instance of OCVotingComparison.
- #set_people ⇒ Object
- #set_votes ⇒ Object
Methods inherited from OpenCongressObject
construct_url, hash2get, make_call, parse_supporting_results
Constructor Details
#initialize(params) ⇒ OCVotingComparison
Returns a new instance of OCVotingComparison.
8 9 10 11 12 13 14 15 16 |
# File 'lib/opencongress/voting_comparison.rb', line 8 def initialize(params) params.each do |key, value| instance_variable_set("@#{key}", value) if OCVotingComparison.instance_methods.include? key end set_people set_votes end |
Instance Attribute Details
#hot_votes ⇒ Object
Returns the value of attribute hot_votes.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def hot_votes @hot_votes end |
#other_votes ⇒ Object
Returns the value of attribute other_votes.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def other_votes @other_votes end |
#percentage ⇒ Object
Returns the value of attribute percentage.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def percentage @percentage end |
#person1 ⇒ Object
Returns the value of attribute person1.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def person1 @person1 end |
#person2 ⇒ Object
Returns the value of attribute person2.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def person2 @person2 end |
#same_vote ⇒ Object
Returns the value of attribute same_vote.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def same_vote @same_vote end |
#shared_committees ⇒ Object
Returns the value of attribute shared_committees.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def shared_committees @shared_committees end |
#total_votes ⇒ Object
Returns the value of attribute total_votes.
5 6 7 |
# File 'lib/opencongress/voting_comparison.rb', line 5 def total_votes @total_votes end |
Instance Method Details
#set_people ⇒ Object
19 20 21 22 |
# File 'lib/opencongress/voting_comparison.rb', line 19 def set_people self.person1 = OCPerson.new(self.person1["person"]) self.person2 = OCPerson.new(self.person2["person"]) end |
#set_votes ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/opencongress/voting_comparison.rb', line 24 def set_votes these_hot_votes = [] hot_votes["vote"].each do |v| nv = OCRollCallComparison.new(v) these_hot_votes << nv end self.hot_votes = these_hot_votes these_other_votes = [] other_votes["vote"].each do |v| nv = OCRollCallComparison.new(v) these_other_votes << nv end self.other_votes = these_other_votes end |