NAME

Data::Taxonomy::Tags - Represents a set of tags for any item

SYNOPSIS

use Data::Taxonomy::Tags;

my $tags = Data::Taxonomy::Tags->new('perl tags cpan module system:meta');

print $_, "\n" for $tags->tags;

print $_, "\n" for $tags->categories;

DESCRIPTION

Data::Taxonomy::Tags will basically take care of managing tags for an item easier. You provide it with a string of tags and it'll allow you to call methods to get all the tags and categories as well as add and delete tags from the list.

Methods

new($string[,\%options])

The first argument is a string of tags. This string is stripped of any leading and trailing whitespace. The second argument, which is optional, is a hashref of options.

Returns a Data::Taxonomy::Tags object;

separator => ['\s+', ' ']

Specifies the regex pattern (or compiled regex) which will be used to split the tags apart and the character(s) used between tags when converting the object back to a string. Make sure to escape any special characters in the regex pattern.

If the value is not an arrayref, then the same value is used for both operations (and is escaped for the regex).

Defaults to ['\s+', ' '].

category => [':', ':']

Specifies the regex pattern (or compiled regex) which will be used to split the tag name from it's optional category and the character(s) used between the category and tag when converting to a string. Make sure to escape any special characters in the regex pattern.

If the value is not an arrayref, then the same value is used for both operations (and is escaped for the regex).

Defaults to [':', ':'].

tags

Returns an array or arrayref (depending on context) of Data::Taxonomy::Tags::Tag objects.

add_to_tags($tags)

Processes the string and adds the tag(s) to the object.

remove_from_tags($tags)

Processes the string and removes the tag(s) from the object.

remove_category($category)

Removes all tags with the specified category.

categories

Returns an array or arrayref (depending on context) of the unique categories.

tags_with_category($category)

Returns an array or arrayref (depending on context) of the tags with the specified category

as_string

Returns the tag list as a string (that is, what was given to the constructor). Overloading is used as well to automatically call this method if the object is used in a string context.

BUGS

All bugs, open and resolved, are handled by RT at https://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Taxonomy-Tags.

Please report all bugs via https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Taxonomy-Tags.

LICENSE

Copyright 2005, Thomas R. Sibley.

You may use, modify, and distribute this package under the same terms as Perl itself.

AUTHOR

Thomas R. Sibley, http://zulutango.org:82/