Fix runtime errors in RubyVote introduced.
<div class="clearbox"></div>
<h2>Voters</h2>
-
<table class="voterbox">
<tr>
<th>IP Address</th>
<%= `host #{IPAddr.new(voter.ipaddress).to_s}`.sub(/^.*pointer (.*)\.$/, '\1') %>
<% rescue ArgumentError => err %>
- <%= " - " %>
+ <%= voter.ipaddress %>
<% end %>
</td>
<td><%= voter.vote.votestring %></td>
<% end %>
</table>
+ <%= render :partial => 'pref_table' %>
+
<%= image_tag( graph_url( :action => 'votes_per_day', :id => @election ) ) %><br />
<%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%><br />
<%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %><br />
<%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %>
-
class PluralityResult < ElectionResult
attr_reader :ranked_candidates
-
+ attr_reader :points
+
def initialize(voteobj=nil)
super(voteobj)
b[1] <=> a[1]
end.collect {|a| a[0]}
- @points = self.election.votes
++ @points = @election.votes
+
# winners are anyone who has the same number of votes as the
# first person
@winners = @ranked_candidates.find_all do |i|
end
super(votes)
end
-
+
def tally_vote(vote)
points = candidates.length - 1
vote.each do |candidate|
points -= 1
end
end
-
+
def verify_vote(vote=nil)
vote.instance_of?( Array ) and
vote == vote.uniq
class BordaResult < ElectionResult
attr_reader :ranked_candidates
+ attr_reader :points
def initialize(voteobj=nil)
super(voteobj)
votes = @election.votes
-
+
@ranked_candidates = votes.sort do |a, b|
b[1] <=> a[1]
end.collect {|i| i[0]}
@winners = @ranked_candidates.find_all do |i|
votes[i] == votes[@ranked_candidates[0]]
end
- @points = self.election.votes
+
++ @points = @election.votes
end
end