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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ 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) (boolean)

{ since => '0.08', }

=example-1 tv

package main;

my $example = Example->new;

my $result = $example->tv($example);

# 1

t/Venus.t: present: authors t/Venus.t: present: license

64 POD Errors

The following errors were encountered while parsing the POD:

Around line 14:

Unknown directive: =name

Around line 22:

Unknown directive: =tagline

Around line 30:

Unknown directive: =abstract

Around line 38:

Unknown directive: =includes

Around line 56:

Unknown directive: =synopsis

Around line 87:

Unknown directive: =description

Around line 96:

Unknown directive: =method

Around line 103:

Unknown directive: =signature

Around line 107:

Unknown directive: =metadata

Around line 143:

=cut found outside a pod block. Skipping to next block.

Around line 163:

=cut found outside a pod block. Skipping to next block.

Around line 173:

Unknown directive: =method

Around line 180:

Unknown directive: =signature

Around line 184:

Unknown directive: =metadata

Around line 220:

=cut found outside a pod block. Skipping to next block.

Around line 240:

=cut found outside a pod block. Skipping to next block.

Around line 250:

Unknown directive: =method

Around line 258:

Unknown directive: =signature

Around line 262:

Unknown directive: =metadata

Around line 298:

=cut found outside a pod block. Skipping to next block.

Around line 318:

=cut found outside a pod block. Skipping to next block.

Around line 328:

Unknown directive: =method

Around line 335:

Unknown directive: =signature

Around line 339:

Unknown directive: =metadata

Around line 375:

=cut found outside a pod block. Skipping to next block.

Around line 395:

=cut found outside a pod block. Skipping to next block.

Around line 405:

Unknown directive: =method

Around line 412:

Unknown directive: =signature

Around line 416:

Unknown directive: =metadata

Around line 452:

=cut found outside a pod block. Skipping to next block.

Around line 472:

=cut found outside a pod block. Skipping to next block.

Around line 482:

Unknown directive: =method

Around line 489:

Unknown directive: =signature

Around line 493:

Unknown directive: =metadata

Around line 529:

=cut found outside a pod block. Skipping to next block.

Around line 549:

=cut found outside a pod block. Skipping to next block.

Around line 559:

Unknown directive: =method

Around line 566:

Unknown directive: =signature

Around line 570:

Unknown directive: =metadata

Around line 606:

=cut found outside a pod block. Skipping to next block.

Around line 626:

=cut found outside a pod block. Skipping to next block.

Around line 636:

Unknown directive: =method

Around line 643:

Unknown directive: =signature

Around line 647:

Unknown directive: =metadata

Around line 683:

=cut found outside a pod block. Skipping to next block.

Around line 703:

=cut found outside a pod block. Skipping to next block.

Around line 713:

Unknown directive: =method

Around line 720:

Unknown directive: =signature

Around line 724:

Unknown directive: =metadata

Around line 760:

=cut found outside a pod block. Skipping to next block.

Around line 780:

=cut found outside a pod block. Skipping to next block.

Around line 790:

Unknown directive: =method

Around line 796:

Unknown directive: =signature

Around line 800:

Unknown directive: =metadata

Around line 838:

=cut found outside a pod block. Skipping to next block.

Around line 860:

=cut found outside a pod block. Skipping to next block.

Around line 886:

=cut found outside a pod block. Skipping to next block.

Around line 896:

Unknown directive: =method

Around line 903:

Unknown directive: =signature

Around line 907:

Unknown directive: =metadata

Around line 945:

=cut found outside a pod block. Skipping to next block.

Around line 967:

=cut found outside a pod block. Skipping to next block.

Around line 989:

=cut found outside a pod block. Skipping to next block.

Around line 999:

Unknown directive: =partials