projects
/
selectricity
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a new bar graph, that counts how many points the borda system of
[selectricity]
/
lib
/
rubyvote
/
positional.rb
diff --git
a/lib/rubyvote/positional.rb
b/lib/rubyvote/positional.rb
index 11e8a499a9fdceb4a517677545017bb829af8cb8..3de3fb29ae6f20b0371eedacb41471ff73be279f 100644
(file)
--- 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|
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
points -= 1
end
end
@@
-58,6
+63,8
@@
class BordaVote < ElectionVote
end
class BordaResult < ElectionResult
end
class BordaResult < ElectionResult
+ attr_reader :ranked_candidates
+
def initialize(voteobj=nil)
super(voteobj)
votes = @election.votes
def initialize(voteobj=nil)
super(voteobj)
votes = @election.votes
Benjamin Mako Hill
||
Want to submit a patch?