AI-Fuzzy
view release on metacpan or search on metacpan
lib/AI/Fuzzy/Label.pm view on Meta::CPAN
package AI::Fuzzy::Label;
## Fuzzy Label ####
use overload ( '>' => \&greaterthan,
'<' => \&lessthan,
'>=' => \&greaterequal,
'<=' => \&lessequal,
'<=>'=> \&spaceship,
'""' => \&stringify
);
sub new {
my ($class, $name, $low, $mid, $high) = @_;
my $self = {};
bless $self, $class;
$self->{name} = $name;
$self->{low} = $low;
$self->{mid} = $mid;
$self->{high} = $high;
return $self;
}
sub name {
my ($self, $name) = @_;
$self->{name} = $name if ($name);
return $self->{name};
}
sub stringify {
my $self=shift;
return qq([$self->{name}: $self->{low},$self->{mid},$self->{high}]);
}
sub lessthan {
my ($self, $that) = @_;
if ($self->{low} < $that->{low}) {
return 1;
} else {
return 0;
}
}
sub lessequal {
my ($self, $that) = @_;
if ($self->{low} <= $that->{low}) {
return 1;
} else {
return 0;
}
}
sub greaterthan {
my ($self, $that) = @_;
if ($self->{high} > $that->{high}) {
return 1;
} else {
return 0;
}
}
sub greaterequal {
my ($self, $that) = @_;
if ($self->{high} >= $that->{high}) {
return 1;
} else {
return 0;
}
}
( run in 0.549 second using v1.01-cache-2.11-cpan-39bf76dae61 )