File Coverage

blib/lib/Net/Whois/ARIN/Organization.pm
Criterion Covered Total %
statement 22 50 44.0
branch 6 10 60.0
condition 1 3 33.3
subroutine 6 7 85.7
pod 4 4 100.0
total 39 74 52.7


line stmt bran cond sub pod time code
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 6     6   32 use strict;
  6         149  
  6         275  
36 6     6   32 use Carp "croak";
  6         9  
  6         4303  
37              
38             our $AUTOLOAD;
39              
40             =head1 METHODS
41              
42             =over 4
43              
44             =item B - create a Net::Whois::ARIN::Organization object
45              
46             =cut
47              
48             sub new {
49 1     1 1 2 my $class = shift;
50 1         10 return bless { _contacts => [], @_ }, $class;
51             }
52              
53             =item B - 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             sub contacts {
62 2     2 1 5 my $self = shift;
63 2 100       17 $self->{_contacts} = [ @_ ] if @_;
64 2         6 return @{ $self->{_contacts} };
  2         8  
65             }
66              
67             =over 4
68              
69             =item B - return the current whois record
70              
71             print $o->dump;
72              
73             =back
74              
75             =cut
76              
77             sub dump {
78 0     0 1 0 my $self = shift;
79 0         0 my $record = sprintf "\nOrgName: %s\n", $self->OrgName;
80 0         0 $record .= sprintf "OrgID: %s\n",$self->OrgID;
81 0         0 $record .= sprintf("Address: %s\n", $_) for @{ $self->Address };
  0         0  
82 0         0 $record .= sprintf "City: %s\n",$self->City;
83 0         0 $record .= sprintf "StateProv: %s\n",$self->StateProv;
84 0         0 $record .= sprintf "PostalCode: %s\n",$self->PostalCode;
85 0         0 $record .= sprintf "Country: %s\n",$self->Country;
86 0         0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
87 0         0 $record .= sprintf "Updated: %s\n\n",$self->Updated;
88              
89 0         0 $record .= sprintf "NetRange: %s\n",$self->NetRange;
90 0         0 $record .= sprintf "CIDR: %s\n",$self->CIDR;
91 0         0 $record .= sprintf "NetName: %s\n",$self->NetName;
92 0         0 $record .= sprintf "NetHandle: %s\n",$self->NetHandle;
93 0         0 $record .= sprintf "Parent: %s\n",$self->Parent;
94 0         0 $record .= sprintf "NetType: %s\n",$self->NetType;
95 0         0 $record .= sprintf "Comment: %s\n",$self->Comment;
96 0         0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
97 0         0 $record .= sprintf "Updated: %s\n",$self->Updated;
98              
99 0         0 foreach my $contact ( $self->contacts ) {
100 0         0 $record .= sprintf "%sHandle: %s\n", $contact->Type, $contact->Handle;
101 0         0 $record .= sprintf "%sName: %s\n", $contact->Type, $contact->Name;
102 0         0 $record .= sprintf "%sPhone: %s\n", $contact->Type, $contact->Phone;
103 0         0 $record .= sprintf "%sEmail: %s\n", $contact->Type, $contact->Email;
104             }
105              
106 0         0 return $record;
107             }
108              
109             sub Parent {
110 1     1 1 3 my $self = shift;
111 1 50       5 $self->{Parent} = shift if @_;
112 1         6 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 - get/set the organization name
122              
123             =item B - get/set the organization id
124              
125             =item B
- get/set the address
126              
127             =item B - get/set the city
128              
129             =item B - get/set the state or province
130              
131             =item B - get/set the postal code
132              
133             =item B - get/set the country
134              
135             =item B - get/set the registration date
136              
137             =item B - get/set the last updated date
138              
139             =item B - get/set the network range
140              
141             =item B - get/set the CIDR netblock
142              
143             =item B - get/set the network name
144              
145             =item B - get/set the network handle
146              
147             =item B - get/set the parent network handle
148              
149             =item B - get/set the network type
150              
151             =item B - get/set the public comment
152              
153             =back
154              
155             =cut
156              
157             sub AUTOLOAD {
158 11     11   1487 my $self = shift;
159 11         15 my $name = $AUTOLOAD;
160 11         49 $name =~ s/.*://;
161              
162 11 50       32 return if $name eq 'DESTROY';
163              
164 11 50 33     62 if ($name !~ /^_/ && exists $self->{$name}) {
165 11 50       20 if (@_) {
166 0         0 return $self->{$name} = shift;
167             } else {
168 11         57 return $self->{$name};
169             }
170             }
171              
172 0           croak "Undefined subroutine \&$AUTOLOAD called";
173             }
174              
175             =head1 AUTHOR
176              
177             Todd Caine
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             1;
186             __END__