X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/fc0a6a8d7ea15bcdb27ebdd58721401c7045c6e0..8f3646d179b4d779c9521b6cc1b227f371830395:/lib/rubyvote/positional.rb?ds=sidebyside diff --git a/lib/rubyvote/positional.rb b/lib/rubyvote/positional.rb old mode 100755 new mode 100644 index 11e8a49..3de3fb2 --- 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