summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
00afdac)
[nil] as a winner list for empty elections.
git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@42
1440c7f4-e209-0410-9a04-
881b5eb134a8
protected
def defeats(candidates=nil, votes=nil)
protected
def defeats(candidates=nil, votes=nil)
- candidates = @election.candidates unless candidates
- votes = @election.votes unless votes
+ candidates ||= @election.candidates || []
+ # we're assumign that if there are candidates, there must be at
+ # least one vote for them
+ votes ||= @election.votes
- candidates = [candidates] unless candidates.class == Array
candidates.each do |candidate|
candidates.each do |challenger|
next if candidate == challenger
candidates.each do |candidate|
candidates.each do |challenger|
next if candidate == challenger
def initialize(voteobj=nil)
super(voteobj)
@winners = self.cpssd()
def initialize(voteobj=nil)
super(voteobj)
@winners = self.cpssd()
end
protected
def cpssd
votes = @election.votes
end
protected
def cpssd
votes = @election.votes
- candidates = *@election.candidates
+ candidates = @election.candidates.dup
def in_schwartz_set?(candidate, candidates, transitive_defeats)
candidates.each do |challenger|
def in_schwartz_set?(candidate, candidates, transitive_defeats)
candidates.each do |challenger|