Class: Beatpath::Vote
- Inherits:
-
Object
- Object
- Beatpath::Vote
- Defined in:
- lib/beatpath.rb
Instance Attribute Summary collapse
-
#pairwise_matrix ⇒ Object
readonly
Returns the value of attribute pairwise_matrix.
-
#strongest_paths ⇒ Object
readonly
Returns the value of attribute strongest_paths.
-
#winners ⇒ Object
readonly
Returns the value of attribute winners.
Instance Method Summary collapse
-
#initialize(ballots, candidates = nil) ⇒ Vote
constructor
A new instance of Vote.
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_matrix ⇒ Object (readonly)
Returns the value of attribute pairwise_matrix.
6 7 8 |
# File 'lib/beatpath.rb', line 6 def pairwise_matrix @pairwise_matrix end |
#strongest_paths ⇒ Object (readonly)
Returns the value of attribute strongest_paths.
6 7 8 |
# File 'lib/beatpath.rb', line 6 def strongest_paths @strongest_paths end |
#winners ⇒ Object (readonly)
Returns the value of attribute winners.
6 7 8 |
# File 'lib/beatpath.rb', line 6 def winners @winners end |