Contentment::Term - Interface for Index plugin terms
package Contentment::MyPlugin::Term; use Scalar::Util qw( weaken ); sub new { my ($class, $p) = @_; my $self = bless { name => $p->{name}, index => $p->{index}, generators => $p->{generators}, }, $class; weaken $self->{index}; return $self; } sub name { return shift->{name} } sub index { return shift->{index} } sub generators { return shift->{generators} }
Each term object must implement the features described here. The actual features available in a term depend partly upon the features() method of the index object returning the term.
features()
These are the methods that all terms must define:
This method will return the full string identifying the term. This string should uniquely identify the term within the index.
This can be used to give the term a pretty name.
This can used to give the term a description.
This method will return the original index that spawned it.
This method will return the list (possibly empty) of generators associated with this term. In the case of a term for an index with the $SUBTERMS feature, this should only return the generators which identified directly by the current term.
$SUBTERMS
A term for an index with the $SEARCH feature does not need to define any additional methods.
$SEARCH
A term for an index with the $TERM_LIST feature does not need to define any additional methods.
$TERM_LIST
A term for an index with the $FREEFORM_TERMS feature does not need to define any additional methods.
$FREEFORM_TERMS
A term for an index with the $SUBTERMS feature must define the following methods:
Returns a list (possibly empty) of all the subterms of the current term.
Returns a list (possibly empty) of all generators held directly within this term and indirectly by being held within a subterm. Each generator should be returned exactly once.
A term for an index with the $TERM_LINKS feature must define the following methods:
$TERM_LINKS
Returns a list (possibly empty) of related terms.
A term for an index with the $SYNONYMS feature must define the following methods:
$SYNONYMS
Returns a list (possibly empty) of alternate strings that could be used as the name of the current term.
A term for an index with the $QUANTITATIVE feature does not need to define any additional methods.
$QUANTITATIVE
A term for an index with the $REVERSE feature does not need to define any additional methods.
$REVERSE
A term for an index with the $SCORE feature must define the following methods:
$SCORE
This method returns the score of the term match for the given generator. If the generator is not listed by the generators() method, the score must be 0. Otherwise, the score must be a positive number less than or equal to 100.
generators()
This method should return the same thing as the generators() method, except that each element is not a generator, but a two element array. The first element of the array is the score (a positive number less than or equal to 100). The second element of the array is the generator object.
A term for an index with the $EDIT feature must define the following methods:
$EDIT
This method adds the given generator to the list of generators returned by generators() or throws an exception to indicate failure.
This method removes the given generator from the list of generators returned by generators() or throws an exception to indicate failure.
Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>
Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Contentment, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Contentment
CPAN shell
perl -MCPAN -e shell install Contentment
For more information on module installation, please visit the detailed CPAN module installation guide.