Added get_full_results method that returns a ranked list of candidates.
[rubyvote] / lib / rubyvote / condorcet.rb
index b3bdcd6d71a253671b795a59c70f471d73c1ab15..5f103fb7f659f90e7fe0e01f9f049420afc77cbd 100644 (file)
@@ -62,23 +62,33 @@ class CondorcetVote < ElectionVote
     end
   end
 
+  def result
+    top_result = resultFactory( self )
+    until @candidates.empty?
+      aResult = resultFactory( self )
+      top_result.full_results << aResult
+      filter_out(aResult)
+    end
+    top_result
+  end
+
   protected
   def verify_vote(vote=nil)
     vote.instance_of?( Array ) and
       vote == vote.uniq
   end
-  
+
 end
 
 class PureCondorcetVote < CondorcetVote
-  def result
-    PureCondorcetResult.new( self )
+  def resultFactory(init)
+    PureCondorcetResult.new(init)
   end
 end
 
 class CloneproofSSDVote < CondorcetVote
-  def result
-    CloneproofSSDResult.new( self )
+  def resultFactory(init)
+    CloneproofSSDResult.new(init)
   end
 end
 

Benjamin Mako Hill || Want to submit a patch?