ARIN/Organization.pm

filter: Statementstmt 46.1% 24 / 52 Branchbran 70.0% 7 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 100% 4 / 4 totaltotal 53.8% 42 / 78 CC 9 SCAR 16.3
CC
9
Cov
49%
dump
12.0
AUTOLOAD
5.9
Parent
2.0
CRAP 5.1
« ARIN/AS.pm ↑ Summary ARIN/Contact.pm »
1 package Net::Whois::ARIN::Organization;
2  
3 =head1 NAME
4  
5 Net::Whois::ARIN::Organization - ARIN whois Organization record class
6  
7 =head1 SYNOPSIS
8  
9 use Net::Whois::ARIN::Organization;
10  
11 my $org = Net::Whois::ARIN::Organization->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 Comment => '',
20 RegDate => '1995-07-25',
21 Updated => '2001-05-17',
22 );
23  
24 printf "%s is located in %s, %s\n",
25 $org->OrgName,
26 $org->City,
27 $org->StateProv;
28  
29 =head1 DESCRIPTION
30  
31 The Net::Whois::ARIN::Organization module is simple class which is used to store the attributes of an Organization record in ARIN's Whois server. Each attribute of the Organization record has an accessor/mutator of the same name.
32  
33 =cut
34  
35 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 7 ▶use Carp "croak";
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 7 our $AUTOLOAD;
39  
40 =head1 METHODS
41  
42 =over 4
43  
44 =item B<new> - create a Net::Whois::ARIN::Organization object
45  
46 =cut
47  
48 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
49 1 my $class = shift;
50 1 return bless { _contacts => [], @_ }, $class;
51 }
52  
53 =item B<contacts> - get/set Net::Whois::ARIN::Contact
54  
55 This method accepts a list of Net::Whois::ARIN::Contact and associates these objects with the Organization record. If no arguments are specified, the method returns a list of Net::Whois::ARIN::Contact objects.
56  
57 =back
58  
59 =cut
60  
61 2 ▶sub contacts {
Subroutine contacts: called CC=2 SCAR=6.9
Pod documented
62 2 my $self = shift;
63 2 ▶ $self->{_contacts} = [ @_ ] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 1 2
64 2 return @{ $self->{_contacts} };
65 }
66  
67 =over 4
68  
69 =item B<dump> - return the current whois record
70  
71 print $o->dump;
72  
73 =back
74  
75 =cut
76  
77 0 ▶sub dump {
Subroutine dump: not called CC=3 SCAR=24.8
Pod documented
78 0 my $self = shift;
79 0 my $record = sprintf "\nOrgName: %s\n", $self->OrgName;
80 0 $record .= sprintf "OrgID: %s\n",$self->OrgID;
81 0 $record .= sprintf("Address: %s\n", $_) for @{ $self->Address };
82 0 $record .= sprintf "City: %s\n",$self->City;
83 0 $record .= sprintf "StateProv: %s\n",$self->StateProv;
84 0 $record .= sprintf "PostalCode: %s\n",$self->PostalCode;
85 0 $record .= sprintf "Country: %s\n",$self->Country;
86 0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
87 0 $record .= sprintf "Updated: %s\n\n",$self->Updated;
88  
89 0 $record .= sprintf "NetRange: %s\n",$self->NetRange;
90 0 $record .= sprintf "CIDR: %s\n",$self->CIDR;
91 0 $record .= sprintf "NetName: %s\n",$self->NetName;
92 0 $record .= sprintf "NetHandle: %s\n",$self->NetHandle;
93 0 $record .= sprintf "Parent: %s\n",$self->Parent;
94 0 $record .= sprintf "NetType: %s\n",$self->NetType;
95 0 $record .= sprintf "Comment: %s\n",$self->Comment;
96 0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
97 0 $record .= sprintf "Updated: %s\n",$self->Updated;
98  
99 0 foreach my $contact ( $self->contacts ) {
100 0 $record .= sprintf "%sHandle: %s\n", $contact->Type, $contact->Handle;
101 0 $record .= sprintf "%sName: %s\n", $contact->Type, $contact->Name;
102 0 $record .= sprintf "%sPhone: %s\n", $contact->Type, $contact->Phone;
103 0 $record .= sprintf "%sEmail: %s\n", $contact->Type, $contact->Email;
104 }
105  
106 0 return $record;
107 }
108  
109 1 ▶sub Parent {
Subroutine Parent: called CC=2 SCAR=7.1
Pod documented
110 1 my $self = shift;
111 1 ▶ $self->{Parent} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
112 1 return $self->{Parent};
113 }
114  
115 =head1 ATTRIBUTES
116  
117 These methods are the accessors/mutators for the fields found in the Whois record.
118  
119 =over 4
120  
121 =item B<OrgName> - get/set the organization name
122  
123 =item B<OrgID> - get/set the organization id
124  
125 =item B<Address> - get/set the address
126  
127 =item B<City> - get/set the city
128  
129 =item B<StateProv> - get/set the state or province
130  
131 =item B<PostalCode> - get/set the postal code
132  
133 =item B<Country> - get/set the country
134  
135 =item B<RegDate> - get/set the registration date
136  
137 =item B<Updated> - get/set the last updated date
138  
139 =item B<NetRange> - get/set the network range
140  
141 =item B<CIDR> - get/set the CIDR netblock
142  
143 =item B<NetName> - get/set the network name
144  
145 =item B<NetHandle> - get/set the network handle
146  
147 =item B<Parent> - get/set the parent network handle
148  
149 =item B<NetType> - get/set the network type
150  
151 =item B<Comment> - get/set the public comment
152  
153 =back
154  
155 =cut
156  
157 12 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=17.8
158 12 my $self = shift;
159 12 my $name = $AUTOLOAD;
160 12 $name =~ s/.*://;
161  
162 12 ▶ return if $name eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "DESTROY" 1 11 12
163  
164 11 ▶ if ($name !~ /^_/ && exists $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $name =~ /^_/ and exists $self->{$name}) 11 0 11
Condition33%1/3
not $name =~ /^_/ and exists $self->{$name}
!ll&&!rl&&r
0011
MC/DC0%0/2
not $name =~ /^_/ and exists $self->{$name}
not $name =~ /^_/ exists $self->{$name}
Truth table33%1/3
not(A) and B
A= not $name =~ /^_/B= exists $self->{$name}
ABresult
0X0
100
111
165 11 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 11 11
166 0 return $self->{$name} = shift;
167 } else {
168 11 return $self->{$name};
169 }
170 }
171  
172 0 croak "Undefined subroutine \&$AUTOLOAD called";
173 }
174  
175 =head1 AUTHOR
176  
177 Todd Caine <todd.caine at gmail.com>
178  
179 =head1 COPYRIGHT AND LICENSE
180  
181 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.
182  
183 =cut
184  
185 7 1;
186 __END__
« ARIN/AS.pm ↑ Summary ARIN/Contact.pm »