Algorithm-Voting

 view release on metacpan or  search on metacpan

lib/Algorithm/Voting/Ballot.pm  view on Meta::CPAN


sub new {
    my $class = shift;
    if (@_ == 1) {
        return $class->new(candidate => $_[0]);
    }
    my %valid = (
        candidate => 0,
    );
    my %args = validate(@_, \%valid);
    return bless \%args, $class;
}

=head2 $ballot->candidate()

Returns a scalar (presumably a string, although this is not enforced)
containing the candidate for whom this ballot is cast.

=cut

1;

lib/Algorithm/Voting/Plurality.pm  view on Meta::CPAN

    my $box = Algorithm::Voting::Plurality->new(candidates => \@c);

=cut

sub new {
    my $class = shift;
    my %valid = (
        candidates => { type => ARRAYREF, optional => 1 },
    );
    my %args = validate(@_, \%valid);
    my $self = bless \%args, $class;
    $self->tally({});
    return $self;
}

=head2 $box->candidates

Returns a list containing the candidate names used in the construction of the
ballot box.  If no candidates were specified at construction of the box, the
empty list is returned.

lib/Algorithm/Voting/Sortition.pm  view on Meta::CPAN


sub new {
    my $class = shift;
    my %valid = (
        candidates => 1,
        n          => { default => -1 },
        source     => 0,
        keystring  => 0,
    );
    my %args = validate(@_, \%valid);
    return bless \%args, $class;
}

=head2 $obj->candidates

Returns a list containing the current candidates.

=cut

sub candidates {
    return @{ $_[0]->{candidates} };



( run in 0.917 second using v1.01-cache-2.11-cpan-de7293f3b23 )