- SEE ALSO
- COPYRIGHT AND LICENSE
Lingua::Awkwords::OneOf - random choice from a list of items
This module is not typically used directly, as it will be created and called as part of the pattern parse and then render phases of other code.
Container object for a list of items; upon render one of these items will be picked at random and have render called on it. Whatever that returns will be returned, minus whatever any filters may remove.
List of filters, if any. Use add_filters to set these.
String to replaced filtered values with, the empty string by default.
Where the Math::Random::Discrete object to provide weighted random choices is stored.
Choices are stored here as an array reference.
List of weights for each of the choices.
- add_choice value weight
Adds the given value and its weight to the choices.
- add_filters filter ..
Adds one or more strings as a filter for the render phase. These limit what a unit can generate, e.g.
[x/y/z]^xwould replace a result of
xwith the empty string.
This is used by the add method to invalidate the picker object; call this method if you have manually fiddled with the alts or weights after making a render call.
Picks a random choice and in turn calls render on that, then applies any filters present on that result.
- walk callback
Calls the callback function with itself as the argument, then calls walk on all of the available choices.
Please report any bugs or feature requests to
bug-lingua-awkwords at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-Awkwords.
Patches might best be applied towards:
None at this time.
thrig - Jeremy Mates (cpan:JMATES)
<jmates at cpan.org>
Copyright (C) 2017 by Jeremy Mates
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause