AI::MicroStructure::MultiList - Base class for structures with multiple lists
package AI::MicroStructure::digits; use AI::MicroStructure::MultiList; our @ISA = ( AI::MicroStructure::MultiList ); __PACKAGE__->init(); 1; =head1 NAME AI::MicroStructure::digits - The numbers structure =head1 DESCRIPTION You can count on this module. Almost. =cut __DATA__ # default :all # names primes even two # names primes odd three five seven # names composites even four six eight # names composites odd nine # names other zero one
AI::MicroStructure::MultiList is the base class for all structures that are meant to return a random excerpt from a predefined list divided in categories.
AI::MicroStructure::MultiList
The category is selected at construction time from:
the given category parameter,
category
the default category for the selected structure.
Categories and sub-categories are separated by a / character.
/
AI::MicroStructure::MultiList offers several methods, so that the subclasses are easy to write (see full example in SYNOPSIS):
The constructor of a single instance. An instance will not repeat items until the list is exhausted.
$meta = AI::MicroStructure::digits->new( category => 'primes' ); $meta = AI::MicroStructure::digits->new( category => 'primes/odd' );
The special category :all will use all the items in all categories.
:all
$meta = AI::MicroStructure::digits->new( category => ':all' );
If no category parameter is given, AI::MicroStructure::MultiList will use the class default. If the class doesn't define a default, then :all is used.
init() must be called when the subclass is loaded, so as to read the __DATA__ section and fully initialise it.
Return $count names (default: 1).
1
Using 0 will return the whole list in list context, and the size of the list in scalar context (according to the category parameter passed to the constructor).
0
Return the selected category for this instance.
Return the categories supported by the structure (except :all).
Return a boolean value indicating if the structure contains the given category.
Return the structure name.
Philippe 'BooK' Bruhat, <book@cpan.org>
<book@cpan.org>
Copyright 2006 Philippe 'BooK' Bruhat, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AI::MicroStructure, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::MicroStructure
CPAN shell
perl -MCPAN -e shell install AI::MicroStructure
For more information on module installation, please visit the detailed CPAN module installation guide.