X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/c65b1e11059c5cf510b54c785d4a246215058f70..389db6f5756bc8a2063f4ab786ea71b4c3b53b8f:/lib/rubyvote/positional.rb diff --git a/lib/rubyvote/positional.rb b/lib/rubyvote/positional.rb index 11e8a49..3de3fb2 100644 --- a/lib/rubyvote/positional.rb +++ b/lib/rubyvote/positional.rb @@ -42,7 +42,12 @@ class BordaVote < ElectionVote def tally_vote(vote) points = candidates.length - 1 vote.each do |candidate| - @votes[candidate] = points + #if the candidate exist, add the points, otherwise assign them + if @votes.has_key?(candidate) + @votes[candidate] += points + else + @votes[candidate] = points + end points -= 1 end end @@ -58,6 +63,8 @@ class BordaVote < ElectionVote end class BordaResult < ElectionResult + attr_reader :ranked_candidates + def initialize(voteobj=nil) super(voteobj) votes = @election.votes