File Coverage

blib/lib/Biblio/ILL/ISO/DeliveryAddress.pm
Criterion Covered Total %
statement 23 53 43.4
branch 5 18 27.7
condition 1 3 33.3
subroutine 6 11 54.5
pod 6 6 100.0
total 41 91 45.0


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::DeliveryAddress;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::DeliveryAddress
6              
7             =cut
8              
9 4     4   682 use Biblio::ILL::ISO::ILLASNtype;
  4         12  
  4         115  
10 4     4   2939 use Biblio::ILL::ISO::PostalAddress;
  4         11  
  4         960  
11 4     4   2094 use Biblio::ILL::ISO::SystemAddress;
  4         10  
  4         110  
12              
13 4     4   25 use Carp;
  4         8  
  4         361  
14              
15             =head1 VERSION
16              
17             Version 0.01
18              
19             =cut
20              
21             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     4   4976 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
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             sub new {
70 2     2 1 6 my $class = shift;
71 2         6 my $self = {};
72              
73 2 50       25 if (@_) {
74 2         5 my ($ref1, $ref2) = @_;
75            
76 2 50       16 $self->{"postal-address"} = $ref1 if (ref($ref1) eq "Biblio::ILL::ISO::PostalAddress");
77 2 50       11 $self->{"postal-address"} = $ref2 if (ref($ref2) eq "Biblio::ILL::ISO::PostalAddress");
78 2 50       9 $self->{"electronic-address"} = $ref1 if (ref($ref1) eq "Biblio::ILL::ISO::SystemAddress");
79 2 50       9 $self->{"electronic-address"} = $ref2 if (ref($ref2) eq "Biblio::ILL::ISO::SystemAddress");
80             }
81              
82 2   33     24 bless($self, ref($class) || $class);
83 2         9 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             sub set_postal_address {
109 0     0 1   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             sub set_postal_address_by_obj {
137 0     0 1   my $self = shift;
138 0           my ($objref) = @_;
139              
140 0 0         if (ref($objref) eq "Biblio::ILL::ISO::PostalAddress") {
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             sub set_electronic_address {
161 0     0 1   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             sub set_electronic_address_by_obj {
180 0     0 1   my $self = shift;
181 0           my ($objref) = @_;
182              
183 0 0         if (ref($objref) eq "Biblio::ILL::ISO::SystemAddress") {
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             sub from_asn {
203 0     0 1   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 0         if ($k =~ /^electronic-address$/) {
    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,
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             1;