File Coverage

blib/lib/Net/Whois/ARIN/AS.pm
Criterion Covered Total %
statement 19 42 45.2
branch 5 8 62.5
condition 1 3 33.3
subroutine 5 6 83.3
pod 3 3 100.0
total 33 62 53.2


line stmt bran cond sub pod time code
1             package Net::Whois::ARIN::AS;
2              
3             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 6     6   37 use strict;
  6         12  
  6         227  
40 6     6   29 use Carp "croak";
  6         13  
  6         3930  
41              
42             =head1 METHODS
43              
44             =over 4
45              
46             =item B - create a Net::Whois::ARIN::AS object
47              
48             =cut
49              
50             sub new {
51 1     1 1 2 my $class = shift;
52 1         27 return bless { _contacts => [], @_ }, $class;
53             }
54              
55             =item B - 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             sub contacts {
64 2     2 1 3 my $self = shift;
65 2 100       11 $self->{_contacts} = [ @_ ] if @_;
66 2         3 return @{ $self->{_contacts} };
  2         9  
67             }
68              
69             =over 4
70              
71             =item B - return the current whois record
72              
73             print $o->dump;
74              
75             =back
76              
77             =cut
78              
79             sub dump {
80 0     0 1 0 my $self = shift;
81 0         0 my $record = sprintf "\nOrgName: %s\n",$self->OrgName;
82 0         0 $record .= sprintf "OrgName: %s\n",$self->OrgID;
83 0         0 $record .= sprintf("Address: %s\n", $_) for @{ $self->Address };
  0         0  
84 0         0 $record .= sprintf "City: %s\n",$self->City;
85 0         0 $record .= sprintf "StateProv: %s\n",$self->StateProv;
86 0         0 $record .= sprintf "PostalCode: %s\n",$self->PostalCode;
87 0         0 $record .= sprintf "Country: %s\n",$self->Country;
88 0         0 $record .= sprintf "ASNumber: %s\n",$self->ASNumber;
89 0         0 $record .= sprintf "ASName: %s\n",$self->ASName;
90 0         0 $record .= sprintf "ASHandle: %s\n",$self->ASHandle;
91 0         0 $record .= sprintf "Comment: %s\n",$self->Comment;
92 0         0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
93 0         0 $record .= sprintf "Updated: %s\n\n",$self->Updated;
94              
95 0         0 foreach my $contact ( $self->contacts ) {
96 0         0 $record .= sprintf "%sHandle: %s\n",$contact->Type,$contact->Handle;
97 0         0 $record .= sprintf "%sName: %s\n",$contact->Type,$contact->Name;
98 0         0 $record .= sprintf "%sPhone: %s\n",$contact->Type,$contact->Phone;
99 0         0 $record .= sprintf "%sEmail: %s\n",$contact->Type,$contact->Email;
100             }
101              
102 0         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 - get/set the organization name
112              
113             =item B - get/set the organization id
114              
115             =item B
- get/set the address
116              
117             =item B - get/set the city
118              
119             =item B - get/set the state or province
120              
121             =item B - get/set the postal code
122              
123             =item B - get/set the country
124              
125             =item B - get/set the registration date
126              
127             =item B - get/set the last updated date
128              
129             =item B - get/set the AS number
130              
131             =item B - get/set the AS name
132              
133             =item B - get/set the AS handle
134              
135             =item B - get/set the public comment
136            
137             =back
138              
139             =cut
140              
141             sub AUTOLOAD {
142 12     12   512 my $self = shift;
143 12         16 my $name = $AUTOLOAD;
144 12         53 $name =~ s/.*://;
145              
146 12 50       27 return if $name eq 'DESTROY';
147              
148 12 50 33     79 if ($name !~ /^_/ && exists $self->{$name}) {
149 12 50       26 if (@_) {
150 0         0 return $self->{$name} = shift;
151             } else {
152 12         58 return $self->{$name};
153             }
154             }
155              
156 0           croak "Undefined subroutine \&$AUTOLOAD called";
157             }
158              
159             =head1 AUTHOR
160              
161             Todd Caine
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             1;
170             __END__