GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Role::Comparable(3) User Contributed Perl Documentation Venus::Role::Comparable(3)

Venus::Role::Comparable - Comparable Role

Comparable Role for Perl 5

  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.

This package provides the following methods:

  eq(any $arg) (boolean)

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.

Since 0.08

eq example 1
  package main;
  my $example = Example->new;
  my $result = $example->eq($example);
  # 1
    
eq example 2
  package main;
  my $example = Example->new;
  my $result = $example->eq([1,2]);
  # 0
    
eq example 3
  package main;
  my $example = Example->new;
  my $result = $example->eq({1..4});
  # 0
    

  ge(any $arg) (boolean)

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.

Since 0.08

ge example 1
  package main;
  my $example = Example->new;
  my $result = $example->ge(3);
  # 0
    
ge example 2
  package main;
  my $example = Example->new;
  my $result = $example->ge($example);
  # 1
    
ge example 3
  package main;
  my $example = Example->new;
  my $result = $example->ge([1,2,3]);
  # 0
    

  gele(any $arg1, any $arg2) (boolean)

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.

Since 0.08

gele example 1
  package main;
  my $example = Example->new;
  my $result = $example->gele(1, 3);
  # 1
    
gele example 2
  package main;
  my $example = Example->new;
  my $result = $example->gele(2, []);
  # 0
    
gele example 3
  package main;
  my $example = Example->new;
  my $result = $example->gele(0, '3');
  # 1
    

  gt(any $arg) (boolean)

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.

Since 0.08

gt example 1
  package main;
  my $example = Example->new;
  my $result = $example->gt({1..2});
  # 0
    
gt example 2
  package main;
  my $example = Example->new;
  my $result = $example->gt(1.9998);
  # 1
    
gt example 3
  package main;
  my $example = Example->new;
  my $result = $example->gt(\1_000_000);
  # 0
    

  gtlt(any $arg1, any $arg2) (boolean)

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.

Since 0.08

gtlt example 1
  package main;
  my $example = Example->new;
  my $result = $example->gtlt('1', 3);
  # 1
    
gtlt example 2
  package main;
  my $example = Example->new;
  my $result = $example->gtlt({1..2}, {1..4});
  # 0
    
gtlt example 3
  package main;
  my $example = Example->new;
  my $result = $example->gtlt('.', ['.']);
  # 1
    

  is(any $arg) (boolean)

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.

Since 1.80

is example 1
  package main;
  my $example = Example->new;
  my $result = $example->is($example);
  # 1
    
is example 2
  package main;
  my $example = Example->new;
  my $result = $example->is([1,2]);
  # 0
    
is example 3
  package main;
  my $example = Example->new;
  my $result = $example->is(Example->new);
  # 0
    

  le(any $arg) (boolean)

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.

Since 0.08

le example 1
  package main;
  my $example = Example->new;
  my $result = $example->le('9');
  # 1
    
le example 2
  package main;
  my $example = Example->new;
  my $result = $example->le([1..2]);
  # 1
    
le example 3
  package main;
  my $example = Example->new;
  my $result = $example->le(\1);
  # 0
    

  lt(any $arg) (boolean)

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.

Since 0.08

lt example 1
  package main;
  my $example = Example->new;
  my $result = $example->lt(qr/.*/);
  # 1
    
lt example 2
  package main;
  my $example = Example->new;
  my $result = $example->lt('.*');
  # 0
    
lt example 3
  package main;
  my $example = Example->new;
  my $result = $example->lt('5');
  # 1
    

  ne(any $arg) (boolean)

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.

Since 0.08

ne example 1
  package main;
  my $example = Example->new;
  my $result = $example->ne([1,2]);
  # 1
    
ne example 2
  package main;
  my $example = Example->new;
  my $result = $example->ne([2]);
  # 1
    
ne example 3
  package main;
  my $example = Example->new;
  my $result = $example->ne(qr/2/);
  # 1
    

  st(object $arg) (boolean)

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.

Since 1.80

st example 1
  package main;
  my $example = Example->new;
  my $result = $example->st($example);
  # 1
    
st example 2
  package main;
  use Venus::Number;
  my $example = Example->new;
  my $result = $example->st(Venus::Number->new(2));
  # 0
    
st example 3
  package main;
  use Venus::String;
  my $example = Example->new;
  my $result = $example->st(Venus::String->new('2'));
  # 0
    
st example 4
  package Example2;
  use base 'Example';
  package main;
  use Venus::String;
  my $example = Example2->new;
  my $result = $example->st(Example2->new);
  # 1
    

  tv(any $arg) (boolean)

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.

Since 0.08

tv example 1
  package main;
  my $example = Example->new;
  my $result = $example->tv($example);
  # 1
    
tv example 2
  package main;
  use Venus::Number;
  my $example = Example->new;
  my $result = $example->tv(Venus::Number->new(2));
  # 0
    
tv example 3
  package main;
  use Venus::String;
  my $example = Example->new;
  my $result = $example->tv(Venus::String->new('2'));
  # 0
    
tv example 4
  package main;
  use Venus::String;
  my $example = Example->new;
  my $result = $example->tv(Example->new);
  # 1
    

Awncorp, "awncorp@cpan.org"

Copyright (C) 2022, Awncorp, "awncorp@cpan.org".

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.