source: perl/modules/AIM/lib/Net/OSCAR/Screenname.pm @ 3dcccba

barnowl_perlaim
Last change on this file since 3dcccba was 7a1c90d, checked in by Geoffrey Thomas <geofft@mit.edu>, 13 years ago
Skeleton AIM module, and Net::OSCAR 1.925
  • Property mode set to 100644
File size: 1.1 KB
Line 
1=pod
2
3Net::OSCAR::Screenname -- OSCAR screenname class
4
5This class overrides a few operators to transparently get
6appropriate behavior for OSCAR screennames.  Screennames
7are case-insensitive and whitespace-insensitive.  So, if you
8do
9        $a = Net::OSCAR::Screenname->new("Some Dude");
10        print "Yay!\n" if $a eq "somedude";
11will be true.
12
13=cut
14
15package Net::OSCAR::Screenname;
16
17$VERSION = '1.925';
18$REVISION = '$Revision: 1.24 $';
19
20use strict;
21use vars qw($VERSION);
22
23use Net::OSCAR::Utility qw(normalize);
24
25use overload
26        "cmp" => "compare",
27        '""' => "stringify",
28        "bool" => "boolify";
29
30sub new($$) {
31        return $_[1] if ref($_[0]) or UNIVERSAL::isa($_[1], "Net::OSCAR::Screenname");
32        my $class = ref($_[0]) || $_[0] || "Net::OSCAR::Screenname";
33        shift;
34        my $name = $_[0];
35        my $self = ref($name) eq "SCALAR" ? $name : \"$name";
36        bless $self, $class;
37        return $self;
38}
39
40sub compare {
41        my($self, $comparand) = @_;
42
43        return normalize($$self) cmp normalize($comparand);
44}
45
46sub stringify { my $self = shift; return $$self; }
47
48sub boolify {
49        my $self = shift;
50        return 0 if !defined($$self) or $$self eq "" or $$self eq "0";
51        return 1;
52}
53
541;
Note: See TracBrowser for help on using the repository browser.