Venus::Role::Comparable
Comparable Role
Comparable Role for Perl 5
method: eq method: ge method: gele method: gt method: gtlt method: is method: le method: lt method: ne method: st method: tv
package Example;
use Venus::Class;
base 'Venus::Kind';
with 'Venus::Role::Comparable';
sub numified {
return 2;
}
package main;
my $example = Example->new;
# my $result = $example->eq(2);
This package modifies the consuming package and provides methods for performing numerical and stringwise comparision operations or any object or raw data type.
The eq method performs an "equals" operation using the invocant and the argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
eq(Any $arg) (Bool)
{ since => '0.08', }
=example-1 eq
package main;
my $example = Example->new;
my $result = $example->eq($example);
# 1
The ge method performs a "greater-than-or-equal-to" operation using the invocant and argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
ge(Any $arg) (Bool)
{ since => '0.08', }
=example-1 ge
package main;
my $example = Example->new;
my $result = $example->ge(3);
# 0
The gele method performs a "greater-than-or-equal-to" operation on the 1st argument, and "lesser-than-or-equal-to" operation on the 2nd argument. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
gele(Any $arg1, Any $arg2) (Bool)
{ since => '0.08', }
=example-1 gele
package main;
my $example = Example->new;
my $result = $example->gele(1, 3);
# 1
The gt method performs a "greater-than" operation using the invocant and argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
gt(Any $arg) (Bool)
{ since => '0.08', }
=example-1 gt
package main;
my $example = Example->new;
my $result = $example->gt({1..2});
# 0
The gtlt method performs a "greater-than" operation on the 1st argument, and "lesser-than" operation on the 2nd argument. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
gtlt(Any $arg1, Any $arg2) (Bool)
{ since => '0.08', }
=example-1 gtlt
package main;
my $example = Example->new;
my $result = $example->gtlt('1', 3);
# 1
The is method performs an "is-exactly" operation using the invocant and the argument provided. If the argument provided is blessed and exactly the same as the invocant (i.e. shares the same address space) the operation will return truthy.
is(Any $arg) (Bool)
{ since => '1.80', }
=example-1 is
package main;
my $example = Example->new;
my $result = $example->is($example);
# 1
The le method performs a "lesser-than-or-equal-to" operation using the invocant and argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
le(Any $arg) (Bool)
{ since => '0.08', }
=example-1 le
package main;
my $example = Example->new;
my $result = $example->le('9');
# 1
The lt method performs a "lesser-than" operation using the invocant and argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
lt(Any $arg) (Bool)
{ since => '0.08', }
=example-1 lt
package main;
my $example = Example->new;
my $result = $example->lt(qr/.*/);
# 1
The ne method performs a "not-equal-to" operation using the invocant and argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
ne(Any $arg) (Bool)
{ since => '0.08', }
=example-1 ne
package main;
my $example = Example->new;
my $result = $example->ne([1,2]);
# 1
The st method performs a "same-type" operation using the invocant and argument provided. If the argument provided is an instance of the invocant, or a subclass, the operation will return truthy.
st(Object $arg) (Bool)
{ since => '1.80', }
=example-1 st
package main;
my $example = Example->new;
my $result = $example->st($example);
# 1
The tv method performs a "type-and-value-equal-to" operation using the invocant and argument provided. The operation will be performed as either a numerical or stringwise operation based upon the preference (i.e. the return value of the "comparer" method) of the invocant.
tv(Any $arg) (Bool)
{ since => '0.08', }
=example-1 tv
package main;
my $example = Example->new;
my $result = $example->tv($example);
# 1
t/Venus.t: pdml: authors t/Venus.t: pdml: license
64 POD Errors
The following errors were encountered while parsing the POD:
- Around line 13:
Unknown directive: =name
- Around line 21:
Unknown directive: =tagline
- Around line 29:
Unknown directive: =abstract
- Around line 37:
Unknown directive: =includes
- Around line 55:
Unknown directive: =synopsis
- Around line 86:
Unknown directive: =description
- Around line 95:
Unknown directive: =method
- Around line 102:
Unknown directive: =signature
- Around line 106:
Unknown directive: =metadata
- Around line 142:
=cut found outside a pod block. Skipping to next block.
- Around line 162:
=cut found outside a pod block. Skipping to next block.
- Around line 172:
Unknown directive: =method
- Around line 179:
Unknown directive: =signature
- Around line 183:
Unknown directive: =metadata
- Around line 219:
=cut found outside a pod block. Skipping to next block.
- Around line 239:
=cut found outside a pod block. Skipping to next block.
- Around line 249:
Unknown directive: =method
- Around line 257:
Unknown directive: =signature
- Around line 261:
Unknown directive: =metadata
- Around line 297:
=cut found outside a pod block. Skipping to next block.
- Around line 317:
=cut found outside a pod block. Skipping to next block.
- Around line 327:
Unknown directive: =method
- Around line 334:
Unknown directive: =signature
- Around line 338:
Unknown directive: =metadata
- Around line 374:
=cut found outside a pod block. Skipping to next block.
- Around line 394:
=cut found outside a pod block. Skipping to next block.
- Around line 404:
Unknown directive: =method
- Around line 411:
Unknown directive: =signature
- Around line 415:
Unknown directive: =metadata
- Around line 451:
=cut found outside a pod block. Skipping to next block.
- Around line 471:
=cut found outside a pod block. Skipping to next block.
- Around line 481:
Unknown directive: =method
- Around line 488:
Unknown directive: =signature
- Around line 492:
Unknown directive: =metadata
- Around line 528:
=cut found outside a pod block. Skipping to next block.
- Around line 548:
=cut found outside a pod block. Skipping to next block.
- Around line 558:
Unknown directive: =method
- Around line 565:
Unknown directive: =signature
- Around line 569:
Unknown directive: =metadata
- Around line 605:
=cut found outside a pod block. Skipping to next block.
- Around line 625:
=cut found outside a pod block. Skipping to next block.
- Around line 635:
Unknown directive: =method
- Around line 642:
Unknown directive: =signature
- Around line 646:
Unknown directive: =metadata
- Around line 682:
=cut found outside a pod block. Skipping to next block.
- Around line 702:
=cut found outside a pod block. Skipping to next block.
- Around line 712:
Unknown directive: =method
- Around line 719:
Unknown directive: =signature
- Around line 723:
Unknown directive: =metadata
- Around line 759:
=cut found outside a pod block. Skipping to next block.
- Around line 779:
=cut found outside a pod block. Skipping to next block.
- Around line 789:
Unknown directive: =method
- Around line 795:
Unknown directive: =signature
- Around line 799:
Unknown directive: =metadata
- Around line 837:
=cut found outside a pod block. Skipping to next block.
- Around line 859:
=cut found outside a pod block. Skipping to next block.
- Around line 885:
=cut found outside a pod block. Skipping to next block.
- Around line 895:
Unknown directive: =method
- Around line 902:
Unknown directive: =signature
- Around line 906:
Unknown directive: =metadata
- Around line 944:
=cut found outside a pod block. Skipping to next block.
- Around line 966:
=cut found outside a pod block. Skipping to next block.
- Around line 988:
=cut found outside a pod block. Skipping to next block.
- Around line 998:
Unknown directive: =partials