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   2190 use strict;
  4         7  
  4         126  
2 4     4   21 use warnings;
  4         8  
  4         651  
3             package App::Addex::Entry::EmailAddress 0.027;
4             # ABSTRACT: an address book entry's email address
5              
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 342 my ($class, $arg) = @_;
30              
31 48 100       120 $arg = { address => $arg } if not ref $arg;
32 48 100 100     164 undef $arg->{label} if defined $arg->{label} and not length $arg->{label};
33              
34 48         80 for (qw(sends receives)) {
35 96 50       208 $arg->{$_} = 1 unless exists $arg->{$_};
36             }
37              
38 48         198 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   44 use overload '""' => 'address';
  4         10  
  4         43  
48              
49             sub address {
50             $_[0]->{address}
51 65     65 1 274 }
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             $_[0]->{label}
61 8     8 1 21 }
62              
63             #pod =method sends
64             #pod
65             #pod =method receives
66             #pod
67             #pod =cut
68              
69 18     18 1 114 sub sends { $_[0]->{sends} }
70 21     21 1 74 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.027
87              
88             =head1 SYNOPSIS
89              
90             An App::Addex::Entry::EmailAddress object represents, well, an addess for an
91             entry.
92              
93             =head1 PERL VERSION SUPPORT
94              
95             This module has the same support period as perl itself: it supports the two
96             most recent versions of perl. (That is, if the most recently released version
97             is v5.40, then this module should work on both v5.40 and v5.38.)
98              
99             Although it may work on older versions of perl, no guarantee is made that the
100             minimum required version will not be increased. The version may be increased
101             for any reason, and there is no promise that patches will be accepted to lower
102             the minimum required perl.
103              
104             =head1 METHODS
105              
106             =head2 new
107              
108             my $address = App::Addex::Entry::EmailAddress->new("dude@example.aero");
109              
110             my $address = App::Addex::Entry::EmailAddress->new(\%arg);
111              
112             Valid arguments are:
113              
114             address - the contact's email address
115             label - the label for this contact (home, work, etc)
116             there is no guarantee that labels are defined or unique
117              
118             sends - if true, this address may send mail; default: true
119             receives - if true, this address may receive mail; default: true
120              
121             =head2 address
122              
123             This method returns the email address as a string.
124              
125             =head2 label
126              
127             This method returns the address label, if any.
128              
129             =head2 sends
130              
131             =head2 receives
132              
133             =head1 AUTHOR
134              
135             Ricardo SIGNES <rjbs@semiotic.systems>
136              
137             =head1 COPYRIGHT AND LICENSE
138              
139             This software is copyright (c) 2006 by Ricardo SIGNES.
140              
141             This is free software; you can redistribute it and/or modify it under
142             the same terms as the Perl 5 programming language system itself.
143              
144             =cut