ARIN/AS.pm

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