lib/Biblio/ILL/ISO/DeliveryAddress.pm

filter: Statementstmt 45.4% 25 / 55 Branchbran 27.7% 5 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 54.5% 6 / 11 Podpod 100% 6 / 6 totaltotal 45.2% 43 / 95 CC 12 SCAR 20.5
CC
12
Cov
41%
from_asn
20.0
new
8.4
set_postal_address_by_obj
6.0
CRAP 7.8
« lib/Biblio/ILL/ISO/NameOfPersonOrInstitution.pm ↑ Summary lib/Biblio/ILL/ISO/SystemAddress.pm »
1 package Biblio::ILL::ISO::DeliveryAddress;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::DeliveryAddress
6  
7 =cut
8  
9 4 ▶use Biblio::ILL::ISO::ILLASNtype;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Biblio::ILL::ISO::PostalAddress;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Biblio::ILL::ISO::SystemAddress;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 VERSION
16  
17 Version 0.01
18  
19 =cut
20  
21 4 our $VERSION = '0.01';
22 #---------------------------------------------------------------------------
23 # Mods
24 # 0.01 - 2003.07.15 - original version
25 #---------------------------------------------------------------------------
26  
27 =head1 DESCRIPTION
28  
29 Biblio::ILL::ISO::DeliveryAddress is a derivation of Biblio::ILL::ISO::ILLASNtype.
30  
31 =head1 USES
32  
33 Biblio::ILL::ISO::PostalAddress
34 Biblio::ILL::ISO::SystemAddress
35  
36 =head1 USED IN
37  
38 Biblio::ILL::ISO::Request
39  
40 =cut
41  
42 4 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 =head1 FROM THE ASN DEFINITION
45
46 Delivery-Address ::= SEQUENCE {
47 postal-address [0] IMPLICIT Postal-Address OPTIONAL,
48 electronic-address [1] IMPLICIT System-Address OPTIONAL
49 }
50  
51 =cut
52  
53 =head1 METHODS
54  
55 =cut
56  
57 #---------------------------------------------------------------
58 #
59 #---------------------------------------------------------------
60 =head1
61  
62 =head2 new( $address [, $another_address] )
63  
64 Creates a new DeliveryAddress object.
65 Expects an address (either a Biblio::ILL::ISO::PostalAddress or a Biblio::ILL::ISO::SystemAddress), and
66 (optionally) another address (either a Biblio::ILL::ISO::PostalAddress or a Biblio::ILL::ISO::SystemAddress).
67  
68 =cut
69 2 ▶sub new {
Subroutine new: called CC=7 SCAR=21.3
Pod documented
70 2 my $class = shift;
71 2 my $self = {};
72  
73 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 0 2
74 2 my ($ref1, $ref2) = @_;
75
76 2 ▶ $self->{"postal-address"} = $ref1 if (ref($ref1) eq "Biblio::ILL::ISO::PostalAddress");
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref1 eq "Biblio::ILL::ISO::PostalAddress" 0 2 2
77 2 ▶ $self->{"postal-address"} = $ref2 if (ref($ref2) eq "Biblio::ILL::ISO::PostalAddress");
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref2 eq "Biblio::ILL::ISO::PostalAddress" 2 0 2
78 2 ▶ $self->{"electronic-address"} = $ref1 if (ref($ref1) eq "Biblio::ILL::ISO::SystemAddress");
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref1 eq "Biblio::ILL::ISO::SystemAddress" 2 0 2
79 2 ▶ $self->{"electronic-address"} = $ref2 if (ref($ref2) eq "Biblio::ILL::ISO::SystemAddress");
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref2 eq "Biblio::ILL::ISO::SystemAddress" 0 2 2
80 }
81  
82 2 ▶ bless($self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
83 2 return ($self);
84 }
85  
86  
87 #---------------------------------------------------------------
88 #
89 #---------------------------------------------------------------
90 =head1
91  
92 =head2 set_postal_address($iname,$pname,$extended,$street,$box,$city,$region,$country,$postcode)
93  
94 Sets the object's postal-address.
95 Expects an institution name (text string),
96 a person name (text string),
97 an "extended address" (text string),
98 a street-and-number (text string),
99 a post office box (text string),
100 a city (text string),
101 a region (text string),
102 a country (text string), and
103 a postal code (text string).
104  
105 Strangely, *all* parameters are optional. Pass empty strings ("") for NULL values.
106  
107 =cut
108 0 ▶sub set_postal_address {
Subroutine set_postal_address: not called CC=1 SCAR=6.9
Pod documented
109 0 my $self = shift;
110 0 my ($iname, $pname, $extended, $street, $box,
111 $city, $region, $country, $postcode) = @_;
112
113 0 $self->{"postal-address"} = new Biblio::ILL::ISO::PostalAddress($iname,
114 $pname,
115 $extended,
116 $street,
117 $box,
118 $city,
119 $region,
120 $country,
121 $postcode);
122 0 return;
123 }
124  
125 #---------------------------------------------------------------
126 #
127 #---------------------------------------------------------------
128 =head1
129  
130 =head2 set_postal_address_by_obj($postal_address)
131  
132 Sets the object's postal-address.
133 Expects a valid Biblio::ILL::ISO::PostalAddress.
134  
135 =cut
136 0 ▶sub set_postal_address_by_obj {
Subroutine set_postal_address_by_obj: not called CC=2 SCAR=17.9
Pod documented
137 0 my $self = shift;
138 0 my ($objref) = @_;
139  
140 0 ▶ if (ref($objref) eq "Biblio::ILL::ISO::PostalAddress") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $objref eq 'Biblio::ILL::ISO::PostalAddress') { } 0 0 0
141 0 $self->{"postal-address"} = $objref;
142 } else {
143 0 croak "Not a PostalAddress";
144 }
145 0 return;
146 }
147  
148 #---------------------------------------------------------------
149 #
150 #---------------------------------------------------------------
151 =head1
152  
153 =head2 set_electronic_address($id, $addr)
154  
155 Sets the objects electronic-address (a Biblio::ILL::ISO::SystemAddress).
156 Expects an ID (text string), and
157 an address (text string).
158  
159 =cut
160 0 ▶sub set_electronic_address {
Subroutine set_electronic_address: not called CC=1 SCAR=6.9
Pod documented
161 0 my $self = shift;
162 0 my ($id, $addr) = @_;
163
164 0 $self->{"electronic-address"} = new Biblio::ILL::ISO::SystemAddress($id, $addr);
165 0 return;
166 }
167  
168 #---------------------------------------------------------------
169 #
170 #---------------------------------------------------------------
171 =head1
172  
173 =head2 set_electronic_address_by_obj($system_address)
174  
175 Sets the object's electronic-address.
176 Expects a valid Biblio::ILL::ISO::SystemAddress.
177  
178 =cut
179 0 ▶sub set_electronic_address_by_obj {
Subroutine set_electronic_address_by_obj: not called CC=2 SCAR=17.9
Pod documented
180 0 my $self = shift;
181 0 my ($objref) = @_;
182  
183 0 ▶ if (ref($objref) eq "Biblio::ILL::ISO::SystemAddress") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $objref eq 'Biblio::ILL::ISO::SystemAddress') { } 0 0 0
184 0 $self->{"electronic-address"} = $objref;
185 } else {
186 0 croak "Not a SystemAddress";
187 }
188 0 return;
189 }
190  
191  
192 #---------------------------------------------------------------
193 #
194 #---------------------------------------------------------------
195 =head1
196  
197 =head2 from_asn($href)
198  
199 Given a properly formatted hash, builds the object.
200  
201 =cut
202 0 ▶sub from_asn {
Subroutine from_asn: not called CC=4 SCAR=30.0
Pod documented
203 0 my $self = shift;
204 0 my $href = shift;
205  
206 0 foreach my $k (keys %$href) {
207 #print ref($self) . "...$k\n";
208  
209 0 ▶ if ($k =~ /^electronic-address$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ /^electronic-address$/) { } 0 0 0
elsif ($k =~ /^postal-address$/) { } 0 0 0
210 0 $self->{$k} = new Biblio::ILL::ISO::SystemAddress();
211 0 $self->{$k}->from_asn($href->{$k});
212  
213 } elsif ($k =~ /^postal-address$/) {
214 0 $self->{$k} = new Biblio::ILL::ISO::PostalAddress();
215 0 $self->{$k}->from_asn($href->{$k});
216  
217 } else {
218 0 croak "invalid " . ref($self) . " element: [$k]";
219 }
220  
221 }
222 0 return $self;
223 }
224  
225 =head1 SEE ALSO
226  
227 See the README for system design notes.
228 See the parent class(es) for other available methods.
229  
230 For more information on Interlibrary Loan standards (ISO 10160/10161),
231 a good place to start is:
232  
233 http://www.nlc-bnc.ca/iso/ill/main.htm
234  
235 =cut
236  
237 =head1 AUTHOR
238  
239 David Christensen, <DChristensenSPAMLESS@westman.wave.ca>
240  
241 =cut
242  
243  
244 =head1 COPYRIGHT AND LICENSE
245  
246 Copyright 2003 by David Christensen
247  
248 This library is free software; you can redistribute it and/or modify it
249 under the same terms as Perl itself.
250  
251 =cut
252  
253 4 1;
« lib/Biblio/ILL/ISO/NameOfPersonOrInstitution.pm ↑ Summary lib/Biblio/ILL/ISO/SystemAddress.pm »