=head1 NAME

OpenDirectory::Category -- A category in OpenDirectory.

=cut





package OpenDirectory::Category;


use strict;

use Data::Dumper;

use IO;

use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET POST);
use HTML::Entities;
use HTML::Parse;





=head1 PROPERTIES

=head2 category

The category as a string. Each sub-category is / separated.

The category hierarchy starts with /, and the Top category 
isn't included. The categoy ends with a /. 

When set, the category is massaged into this format.

Default: "/"

=cut
sub category { my $self = shift; my $pkg = ref($self);
	my ($val) = @_;

	if(defined($val)) {
		$val =~ s{^Top/}{/}; 		#Remove "Top/"
		$val =~ s{^([^/])}{/$1};	#It starts with /
		$val =~ s{([^/])$}{$1/};	#It ends with /
		
		$self->{category} = $val;
		}

	return($self->{category});
	}





=head2 url

The dmoz URL for the category.

Readonly.

=cut
sub url { my $self = shift; my $pkg = ref($self);
	return("http://dmoz.org" . $self->category());
	}





=head2 scoreMatch

How good a match against this category some piece of 
text/url is. 0..

Default: 0

=cut
sub scoreMatch { my $self = shift; my $pkg = ref($self);
	my ($val) = @_;

	if(defined($val)) {
		$val = 0 if($val < 0);
		$self->{scoreMatch} = $val + 0;
		}

	return($self->{scoreMatch});
	}





=head1 METHODS

=head2 new([$category = "/"], [$scoreMatch = 0])

Create new object.

=cut
sub new { my $pkg = shift; $pkg = ref($pkg) || $pkg;
	my ($category, $scoreMatch) = @_;
	defined($category) or $category = "/";
	defined($scoreMatch) or $scoreMatch = "0";

	my $self = {
		};
	bless $self, $pkg;

	$self->category($category);
	$self->scoreMatch($scoreMatch);

	return($self);
	}





=head1 AUTHOR

Johan Lindström - johanl@bahnhof.se

Copyright (c) 2002.. Johan Lindström. All rights reserved. 
This program is free software; you can redistribute it 
and/or modify it under the same terms as Perl itself.

=cut





1;





#EOF
