Sha256: 978107dc572a53a4691661d214858902dd1ff4685b7ee84c7ed7d00bedf56946

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

# encoding: UTF-8
require 'matrix'

module Vote
  module Condorcet
    module Schulze

      class Input

        @vote_matrix = nil

        def initialize candidate_count, vote_list
          @vote_matrix = Matrix.scalar(candidate_count,0)
          insert_vote_array(vote_list) if vote_list.is_a?(Array)
          insert_vote_file(vote_list) if vote_list.is_a?(File)
        end

        def insert_vote_array va
          va.each do |vote|
            @vote_matrix.each_with_index do |e,x,y|
              next if x==y
              @vote_matrix[x,y] += 1 if vote[x]>vote[y]
            end
          end
        end

        def insert_vote_list vl
          #...
        end

        def insert_vote_file vf
          #...
        end

        def matrix
          @vote_matrix
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vote-schulze-0.0.1 lib/vote/condorcet/schulze/input.rb