File Coverage

blib/lib/Net/Whois/ARIN/Customer.pm
Criterion Covered Total %
statement 19 46 41.3
branch 5 8 62.5
condition 1 3 33.3
subroutine 5 6 83.3
pod 3 3 100.0
total 33 66 50.0


line stmt bran cond sub pod time code
1             package Net::Whois::ARIN::Customer;
2              
3             =head1 NAME
4              
5             Net::Whois::ARIN::Customer - ARIN whois Customer record class
6              
7             =head1 SYNOPSIS
8              
9             use Net::Whois::ARIN::Customer;
10              
11             my $cust = Net::Whois::ARIN::Customer->new(
12             CustName => 'Electric Lightwave Inc',
13             Address => '4400 NE 77th Ave',
14             City => 'Vancouver',
15             StateProv => 'WA',
16             PostalCode => '98662',
17             Country => 'US',
18             Comment => '',
19             RegDate => '1995-07-25',
20             Updated => '2001-05-17',
21             );
22              
23             printf "%s is located in %s, %s\n",
24             $cust->CustName,
25             $cust->City,
26             $cust->StateProv;
27              
28             =head1 DESCRIPTION
29              
30             The Net::Whois::ARIN::Customer module is simple class which is used to store the attributes of an Customer record in A
31             RIN's Whois server. Each attribute of the Customer record has an accessor/mutator of the same name.
32              
33             =cut
34              
35 6     6   30 use strict;
  6         10  
  6         221  
36 6     6   33 use Carp "croak";
  6         17  
  6         4035  
37              
38             our $AUTOLOAD;
39              
40             =head1 METHODS
41              
42             =over 4
43              
44             =item B - create a Net::Whois::ARIN::Customer object
45              
46             =back
47              
48             =cut
49              
50             sub new {
51 1     1 1 4 my $class = shift;
52 1         14 return bless { _contacts => [], @_ }, $class;
53             }
54              
55             =over 4
56              
57             =item B - get/set Net::Whois::ARIN::Contact
58              
59             This method accepts a list of Net::Whois::ARIN::Contact and associates these objects with the Organization record. If no argu
60             ments are specified, the method returns a list of Net::Whois::ARIN::Contact objects.
61              
62             =back
63              
64             =cut
65              
66             sub contacts {
67 2     2 1 4 my $self = shift;
68 2 100       13 $self->{_contacts} = [ @_ ] if @_;
69 2         14 return @{ $self->{_contacts} };
  2         22  
70             }
71              
72             =over 4
73              
74             =item B - return the current whois record
75              
76             print $o->dump;
77              
78             =back
79              
80             =cut
81              
82             sub dump {
83 0     0 1 0 my $self = shift;
84 0         0 my $record = sprintf "\nCustName: %s\n", $self->CustName;
85 0         0 $record .= sprintf("Address: %s\n", $_) for @{ $self->Address };
  0         0  
86 0         0 $record .= sprintf "City: %s\n",$self->City;
87 0         0 $record .= sprintf "StateProv: %s\n",$self->StateProv;
88 0         0 $record .= sprintf "PostalCode: %s\n",$self->PostalCode;
89 0         0 $record .= sprintf "Country: %s\n",$self->Country;
90 0         0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
91 0         0 $record .= sprintf "Updated: %s\n\n",$self->Updated;
92              
93 0         0 $record .= sprintf "NetRange: %s\n",$self->NetRange;
94 0         0 $record .= sprintf "CIDR: %s\n",$self->CIDR;
95 0         0 $record .= sprintf "NetName: %s\n",$self->NetName;
96 0         0 $record .= sprintf "NetHandle: %s\n",$self->NetHandle;
97 0         0 $record .= sprintf "Parent: %s\n",$self->Parent;
98 0         0 $record .= sprintf "NetType: %s\n",$self->NetType;
99 0         0 $record .= sprintf "Comment: %s\n",$self->Comment;
100 0         0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
101 0         0 $record .= sprintf "Updated: %s\n",$self->Updated;
102              
103 0         0 foreach my $contact ( $self->contacts ) {
104 0         0 $record .= sprintf "%sHandle: %s\n", $contact->Type, $contact->Handle;
105 0         0 $record .= sprintf "%sName: %s\n", $contact->Type, $contact->Name;
106 0         0 $record .= sprintf "%sPhone: %s\n", $contact->Type, $contact->Phone;
107 0         0 $record .= sprintf "%sEmail: %s\n", $contact->Type, $contact->Email;
108             }
109              
110 0         0 return $record;
111             }
112              
113             =head1 ATTRIBUTES
114              
115             These methods are the accessors/mutators for the fields found in the Whois record.
116              
117             =over 4
118              
119             =item B - get/set the customer name
120              
121             =item B
- get/set the address
122              
123             =item B - get/set the city
124              
125             =item B - get/set the state or province
126              
127             =item B - get/set the postal code
128              
129             =item B - get/set the country
130              
131             =item B - get/set the registration date
132              
133             =item B - get/set the last updated date
134              
135             =item B - get/set the network range
136              
137             =item B - get/set the CIDR netblock
138              
139             =item B - get/set the network name
140              
141             =item B - get/set the network handle
142              
143             =item B - get/set the parent network handle
144              
145             =item B - get/set the network type
146              
147             =item B - get/set the public comment
148              
149             =back
150              
151             =cut
152              
153             sub AUTOLOAD {
154 15     15   1789 my $self = shift;
155 15         30 my $name = $AUTOLOAD;
156 15         72 $name =~ s/.*://;
157              
158 15 50       51 return if $name eq 'DESTROY';
159              
160 15 50 33     96 if ($name !~ /^_/ && exists $self->{$name}) {
161 15 50       39 if (@_) {
162 0         0 return $self->{$name} = shift;
163             } else {
164 15         96 return $self->{$name};
165             }
166             }
167              
168 0           croak "Undefined subroutine \&$AUTOLOAD called";
169             }
170              
171             =head1 AUTHOR
172              
173             Todd Caine
174              
175             =head1 COPYRIGHT AND LICENSE
176              
177             Copyright (c) 2004-2011 Todd Caine. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
178              
179             =cut
180              
181             1;
182             __END__