Skip to content

Commit

Permalink
bring attribute definitions mostly from RankedPairs
Browse files Browse the repository at this point in the history
  • Loading branch information
ikluft committed Nov 24, 2023
1 parent c6497f2 commit e3a1b02
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/perl/kr2/lib/PrefVote/KR2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,33 @@ PrefVote::Core::TestSpec->register_blackbox_spec(
);
__PACKAGE__->ballot_input_ties_policy(1); # set flag for Core: this class allows input ballots to set A/B ties

# list of names of winners in order by place, ties shown by a set of the tied candidates
has winners => (
is => 'rw',
isa => ArrayRef [ Set [Str] ],
default => sub { return [] },
handles_via => 'Array',
handles => {
winners_all => 'all',
winners_count => 'count',
winners_push => 'push',
},
);

# 2-level hash of candidate-pair preference totals
# This shows total votes where 1st index candidate if preferred over a 2nd index candidate.
# Totals are unidirectional and must be combined to determine which candidate has greater number either direction.
has pair => (
is => 'rw',
isa => HashRef [ HashRef [ InstanceOf ['PrefVote::Core::PairData'] ] ],
default => sub { return {} },
handles_via => 'Hash',
handles => {
pair_accessor => 'accessor',
pair_get => 'get',
pair_keys => 'keys',
pair_set => 'set',
},
);

# TODO to be continued...

0 comments on commit e3a1b02

Please sign in to comment.