File Coverage

blib/lib/App/Addex/Entry/EmailAddress.pm
Criterion Covered Total %
statement 19 19 100.0
branch 5 6 83.3
condition 3 3 100.0
subroutine 8 8 100.0
pod 5 5 100.0
total 40 41 97.5


line stmt bran cond sub pod time code
1 4     4   2606 use strict;
  4         10  
  4         132  
2 4     4   24 use warnings;
  4         6  
  4         719  
3             package App::Addex::Entry::EmailAddress;
4             # ABSTRACT: an address book entry's email address
5             $App::Addex::Entry::EmailAddress::VERSION = '0.026';
6             #pod =head1 SYNOPSIS
7             #pod
8             #pod An App::Addex::Entry::EmailAddress object represents, well, an addess for an
9             #pod entry.
10             #pod
11             #pod =method new
12             #pod
13             #pod my $address = App::Addex::Entry::EmailAddress->new("dude@example.aero");
14             #pod
15             #pod my $address = App::Addex::Entry::EmailAddress->new(\%arg);
16             #pod
17             #pod Valid arguments are:
18             #pod
19             #pod address - the contact's email address
20             #pod label - the label for this contact (home, work, etc)
21             #pod there is no guarantee that labels are defined or unique
22             #pod
23             #pod sends - if true, this address may send mail; default: true
24             #pod receives - if true, this address may receive mail; default: true
25             #pod
26             #pod =cut
27              
28             sub new {
29 48     48 1 399 my ($class, $arg) = @_;
30              
31 48 100       143 $arg = { address => $arg } if not ref $arg;
32 48 100 100     239 undef $arg->{label} if defined $arg->{label} and not length $arg->{label};
33              
34 48         122 for (qw(sends receives)) {
35 96 50       510 $arg->{$_} = 1 unless exists $arg->{$_};
36             }
37              
38 48         373 bless $arg => $class;
39             }
40              
41             #pod =method address
42             #pod
43             #pod This method returns the email address as a string.
44             #pod
45             #pod =cut
46              
47 4     4   122 use overload '""' => 'address';
  4         9  
  4         39  
48              
49             sub address {
50 65     65 1 421 $_[0]->{address}
51             }
52              
53             #pod =method label
54             #pod
55             #pod This method returns the address label, if any.
56             #pod
57             #pod =cut
58              
59             sub label {
60 8     8 1 29 $_[0]->{label}
61             }
62              
63             #pod =method sends
64             #pod
65             #pod =method receives
66             #pod
67             #pod =cut
68              
69 18     18 1 172 sub sends { $_[0]->{sends} }
70 21     21 1 103 sub receives { $_[0]->{receives} }
71              
72             1;
73              
74             __END__
75              
76             =pod
77              
78             =encoding UTF-8
79              
80             =head1 NAME
81              
82             App::Addex::Entry::EmailAddress - an address book entry's email address
83              
84             =head1 VERSION
85              
86             version 0.026
87              
88             =head1 SYNOPSIS
89              
90             An App::Addex::Entry::EmailAddress object represents, well, an addess for an
91             entry.
92              
93             =head1 METHODS
94              
95             =head2 new
96              
97             my $address = App::Addex::Entry::EmailAddress->new("dude@example.aero");
98              
99             my $address = App::Addex::Entry::EmailAddress->new(\%arg);
100              
101             Valid arguments are:
102              
103             address - the contact's email address
104             label - the label for this contact (home, work, etc)
105             there is no guarantee that labels are defined or unique
106              
107             sends - if true, this address may send mail; default: true
108             receives - if true, this address may receive mail; default: true
109              
110             =head2 address
111              
112             This method returns the email address as a string.
113              
114             =head2 label
115              
116             This method returns the address label, if any.
117              
118             =head2 sends
119              
120             =head2 receives
121              
122             =head1 AUTHOR
123              
124             Ricardo SIGNES <rjbs@cpan.org>
125              
126             =head1 COPYRIGHT AND LICENSE
127              
128             This software is copyright (c) 2006 by Ricardo SIGNES.
129              
130             This is free software; you can redistribute it and/or modify it under
131             the same terms as the Perl 5 programming language system itself.
132              
133             =cut