Class: Beatpath::Vote

Inherits:
Object
  • Object
show all
Defined in:
lib/beatpath.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ballots, candidates = nil) ⇒ Vote

Returns a new instance of Vote.



8
9
10
11
12
# File 'lib/beatpath.rb', line 8

def initialize(ballots, candidates = nil)
  @pairwise_matrix = VoteMatrix.pairwise_from_ballots(ballots, candidates)
  @strongest_paths = @pairwise_matrix.floyd_warshall
  @winners = @strongest_paths.winners
end

Instance Attribute Details

#pairwise_matrixObject (readonly)

Returns the value of attribute pairwise_matrix.



6
7
8
# File 'lib/beatpath.rb', line 6

def pairwise_matrix
  @pairwise_matrix
end

#strongest_pathsObject (readonly)

Returns the value of attribute strongest_paths.



6
7
8
# File 'lib/beatpath.rb', line 6

def strongest_paths
  @strongest_paths
end

#winnersObject (readonly)

Returns the value of attribute winners.



6
7
8
# File 'lib/beatpath.rb', line 6

def winners
  @winners
end