File Coverage

blib/lib/Net/Whois/ARIN/Network.pm
Criterion Covered Total %
statement 19 49 38.7
branch 5 8 62.5
condition 1 3 33.3
subroutine 5 6 83.3
pod 3 3 100.0
total 33 69 47.8


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