Class: OpenCongress::OCVotingComparison

Inherits:
OpenCongressObject show all
Defined in:
lib/opencongress/voting_comparison.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_votesObject

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_votesObject

Returns the value of attribute other_votes.



5
6
7
# File 'lib/opencongress/voting_comparison.rb', line 5

def other_votes
  @other_votes
end

#percentageObject

Returns the value of attribute percentage.



5
6
7
# File 'lib/opencongress/voting_comparison.rb', line 5

def percentage
  @percentage
end

#person1Object

Returns the value of attribute person1.



5
6
7
# File 'lib/opencongress/voting_comparison.rb', line 5

def person1
  @person1
end

#person2Object

Returns the value of attribute person2.



5
6
7
# File 'lib/opencongress/voting_comparison.rb', line 5

def person2
  @person2
end

#same_voteObject

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_committeesObject

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_votesObject

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_peopleObject



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_votesObject



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