NAME
Games::Go::AGA::Parse::Util - Utilities to help Parse lines from AGA format files
VERSION
version 0.042
SYNOPSIS
use Games::Go::Parse::Util qw( is_Rank ... );
...
if (is_Rank($token)) {
...
}
DESCRIPTION
Utility functions to help parse AGA format files.
Importable functions are:
is_ID
is_Rank
is_Rating
is_Rank_or_Rating
normalize_ID
Rank_to_Rating
- is_ID($id);
-
Returns true if $id is a valid AGA ID, otherwise returns false.
- is_Rank($rank);
-
Returns true if $rank is a valid AGA rank like '3D' or '10k', otherwise returns false.
- is_Rating($rating);
-
Returns true if $rating is a valid AGA numeric rating, otherwise returns false.
- is_Rank_or_Rating($rating);
-
Returns is_Rank($rating) or is_Rating($rating)
- $id = normalize_ID($id);
-
Normalizes IDs. All lower-case letters are converted to upper case. If the ID starts with a digit (e.g. directly from a TDList file), it is pre-pended with 'USA'. Preceding zeros (defined as any zero immediately following a non-digit and followed by a digit) are removed (u01x002 becomes U1X2). All remaining sequences of zeros are shortened to a single zero (u003x00 becomes U3X0).
- $rank = Rank_to_Rating($rank);
-
Converts a $rank (like 3D or 10k) to a numeric rating. If $rank is already a Rating, just returns it unchanged. Dan range adds 0.5, while kyu ranges subtract 0.5 (so 3D = 3.5 and 10K = -10.5). Can throw an exception if $rank is not recognized as a rank or a rating.
AUTHOR
Reid Augustin <reid@hellosix.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 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.