NAME

Games::Go::AGA::DataObjects::Directives - model directives information from an AGA register.tde file

VERSION

version 0.107

SYNOPSIS

use Games::Go::AGA::DataObjects::Directives;

my $directives = Games::Go::AGA::DataObjects::Directives->new;
my $handi = $directives->get_directive_value('HANDICAPS') || 'none';

DESCRIPTION

Games::Go::AGA::DataObjects::Directives models directives information from an AGA register.tde file.

Directives are entered in the register.tde file with two comment characters followed by the directive, followed by the value of the directive:

## TOURNEY  Name of the tournament goes here
## Rules AGA

The Games::Go::AGA::DataObjects::Directives object stores directives as key-value pairs.

Note that AGA directives are not case sensitive. Key matching by this module is similarly case insensitive.

METHODS

@keys = directives()
$count = directives()

In array context, returns the list of directive names. In scalar context, returns the number of directives.

{$key, $value) = get_directive_at_idx($idx)

Returns two element array ('key', 'value') at $idx.

set_directive_at_idx($idx, 'key', 'new value')

Change directive at index $idx to 'key' and 'new value').

delete_directive_at_idx($idx)

Remove the directive and its associated value at $idx.

insert_directive_above($idx, 'key', 'value')

Insert the key and its associated value at (before) $idx. If $idx is undef or greater than the number of directives, the new key and value are added to the end.

delete_directive('key')

Remove key and its associated value from the list of directives.

$value = get_directive_value('key')

Returns the value associated with 'key'. If the key is found, but it has no value (undef or empty string), the return value is the empty string (''). If there are no matching keys, undef is returned. Key matching is not case sensitive.

set_directive_value('key', 'value')

Sets a new value associated with 'key'. If 'key' is not already present, it is added to the end of the Directives list.

SEE ALSO

Games::Go::AGA
Games::Go::AGA::DataObjects
Games::Go::AGA::Parse
Games::Go::AGA::Gtd

AUTHOR

Reid Augustin <reid@hellosix.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Reid Augustin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.