| Asterisk-LCR documentation | Contained in the Asterisk-LCR distribution. |
Asterisk::LCR::Comparer - Generic Route Comparer for Asterisk::LCR
This is a generic class for any Comparer object. Asterisk::LCR::Comparer objects must implement the sortme() method for it to function properly.
none.
Turns $rate into a 1/1, base currency rate.
This method needs to be implemented by subclasses.
Should:
Returns 1 if both objects are equal, 0 otherwise.
Returns 1 if both objects are not equal, 0 otherwise.
Returns 1 if $object1 is strictly greater than $object2, 0 otherwise.
Returns 1 if $object1 is greater or equals than $object2, 0 otherwise.
Returns 1 if $object1 is strictly smaller than $object2, 0 otherwise.
Returns 1 if $object1 is smaller or equals than $object2, 0 otherwise.
| Asterisk-LCR documentation | Contained in the Asterisk-LCR distribution. |
package Asterisk::LCR::Comparer; use base qw /Asterisk::LCR::Object/; use Config::Mini; use warnings; use strict;
sub normalize { my $self = shift; my $rate = shift; $rate->{first_increment} = 1; $rate->{connection_fee} = 0; $rate->{increment} = 1; $rate->{currency} = Config::Mini::get ('comparer')->currency(); }
sub sortme { die "Asterisk::LCR::Comparer::sortme() is a virtual method"; }
sub eq { my $self = shift; return $self->sortme (@_) == 0; }
sub ne { my $self = shift; return not $self->eq (@_); }
sub gt { my $self = shift; return $self->sortme (@_) > 0; }
sub ge { my $self = shift; return $self->gt (@_) or $self->eq (@_); }
sub lt { my $self = shift; return $self->sortme (@_) < 0; }
sub le { my $self = shift; return $self->lt (@_) or $self->eq (@_); } 1; __END__