X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/09c67d9323c7d379d4c6de5dc0457b6de16cff14..d2eb87b3ce3d10f0e8d490d5e248c657125a68a8:/lib/rubyvote/positional.rb diff --git a/lib/rubyvote/positional.rb b/lib/rubyvote/positional.rb index 3de3fb2..056194b 100644 --- a/lib/rubyvote/positional.rb +++ b/lib/rubyvote/positional.rb @@ -38,7 +38,7 @@ class BordaVote < ElectionVote end super(votes) end - + def tally_vote(vote) points = candidates.length - 1 vote.each do |candidate| @@ -51,7 +51,7 @@ class BordaVote < ElectionVote points -= 1 end end - + def verify_vote(vote=nil) vote.instance_of?( Array ) and vote == vote.uniq @@ -64,11 +64,12 @@ end 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]} @@ -76,6 +77,8 @@ class BordaResult < ElectionResult @winners = @ranked_candidates.find_all do |i| votes[i] == votes[@ranked_candidates[0]] end + + @points = @election.votes end end