File Coverage

blib/lib/Biblio/ILL/ISO/HoldPlacedResults.pm
Criterion Covered Total %
statement 31 55 56.3
branch 9 40 22.5
condition 1 3 33.3
subroutine 7 9 77.7
pod 3 3 100.0
total 51 110 46.3


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::HoldPlacedResults;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::HoldPlacedResults
6              
7             =cut
8              
9 4     4   685 use Biblio::ILL::ISO::ILLASNtype;
  4         9  
  4         110  
10 4     4   27 use Biblio::ILL::ISO::ISODate;
  4         9  
  4         85  
11 4     4   23 use Biblio::ILL::ISO::MediumType;
  4         9  
  4         81  
12 4     4   36 use Biblio::ILL::ISO::LocationInfoSequence;
  4         7  
  4         75  
13              
14 4     4   19 use Carp;
  4         9  
  4         429  
15              
16             =head1 VERSION
17              
18             Version 0.01
19              
20             =cut
21              
22             our $VERSION = '0.01';
23             #---------------------------------------------------------------------------
24             # Mods
25             # 0.01 - 2003.07.26 - original version
26             #---------------------------------------------------------------------------
27              
28             =head1 DESCRIPTION
29              
30             Biblio::ILL::ISO::HoldPlacedResults is a derivation of Biblio::ILL::ISO::ILLASNtype.
31              
32             =head1 USES
33              
34             Biblio::ILL::ISO::ISODate;
35             Biblio::ILL::ISO::MediumType;
36             Biblio::ILL::ISO::LocationInfoSequence;
37              
38             =head1 USED IN
39              
40             Biblio::ILL::ISO::ResultsExplanation
41              
42             =cut
43              
44 4     4   2415 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
45              
46             =head1 FROM THE ASN DEFINITION
47            
48             Hold-Placed-Results ::= EXPLICIT SEQUENCE {
49             estimated-date-available [0] IMPLICIT ISO-Date,
50             hold-placed-medium-type [1] IMPLICIT Medium-Type OPTIONAL,
51             locations [2] IMPLICIT SEQUENCE OF Location-Info OPTIONAL
52             }
53              
54             =cut
55              
56             =head1 METHODS
57              
58             =cut
59             #---------------------------------------------------------------
60             #
61             #---------------------------------------------------------------
62             =head1
63              
64             =head2 new( $estimated_date_available [,$medium] [,$locations] )
65              
66             Creates a new HoldPlacedResults object.
67             Expects an estimated-date-available (Biblio::ILL::ISO::ISODate),
68             (optionally) a hold-placed-medium-type (Biblio::ILL::ISO::MediumType), and
69             (optionally) a locations sequence (Biblio::ILL::ISO::LocationInfoSequence).
70              
71             =cut
72             sub new {
73 1     1 1 2 my $class = shift;
74 1         1 my $self = {};
75              
76 1 50       4 if (@_) {
77 1         1 my ($date, $medium, $locations) = @_;
78              
79 1 50       3 croak "missing hold-placed-results estimated-date-available" unless ($date);
80 1 50       10 croak "invalid hold-placed-results estimated-date-available" unless (ref($date) eq "Biblio::ILL::ISO::ISODate");
81              
82 1 50       7 if ($medium) {
83 1 50       3 croak "invalid hold-placed-medium-type" unless (ref($medium) eq "Biblio::ILL::ISO::MediumType");
84             }
85 1 50       4 if ($locations) {
86 1 50       3 croak "invalid locations" unless (ref($locations) eq "Biblio::ILL::ISO::LocationInfoSequence");
87             }
88            
89 1         2 $self->{"estimated-date-available"} = $date;
90 1 50       2 $self->{"hold-placed-medium-type"} = $medium if ($medium);
91 1 50       9 $self->{"locations"} = $locations if ($locations);;
92             }
93              
94 1   33     10 bless($self, ref($class) || $class);
95 1         3 return ($self);
96             }
97              
98              
99             #---------------------------------------------------------------
100             #
101             #---------------------------------------------------------------
102             =head1
103              
104             =head2 set( $estimated_date_available [,$medium] [,$locations] )
105              
106             Sets the object's estimated-date-available (Biblio::ILL::ISO::ISODate),
107             (optionally) hold-placed-medium-type (Biblio::ILL::ISO::MediumType), and
108             (optionally) locations (Biblio::ILL::ISO::LocationInfoSequence).
109              
110             =cut
111             sub set {
112 0     0 1   my $self = shift;
113              
114 0           my ($date, $medium, $locations) = @_;
115              
116 0 0         croak "missing hold-placed-results estimated-date-available" unless ($date);
117 0 0         croak "invalid hold-placed-results estimated-date-available" unless (ref($date) eq "Biblio::ILL::ISO::ISODate");
118              
119 0 0         if ($medium) {
120 0 0         croak "invalid hold-placed-medium-type" unless (ref($medium) eq "Biblio::ILL::ISO::MediumType");
121             }
122 0 0         if ($locations) {
123 0 0         croak "invalid locations" unless (ref($locations) eq "Biblio::ILL::ISO::LocationInfoSequence");
124             }
125            
126 0           $self->{"estimated-date-available"} = $date;
127 0 0         $self->{"hold-placed-medium-type"} = $medium if ($medium);
128 0 0         $self->{"locations"} = $locations if ($locations);;
129            
130 0           return;
131             }
132              
133             #---------------------------------------------------------------
134             #
135             #---------------------------------------------------------------
136             =head1
137              
138             =head2 from_asn($href)
139              
140             Given a properly formatted hash, builds the object.
141              
142             =cut
143             sub from_asn {
144 0     0 1   my $self = shift;
145 0           my $href = shift;
146              
147 0           foreach my $k (keys %$href) {
148             #print ref($self) . "...$k\n";
149              
150 0 0         if ($k =~ /^estimated-date-available$/) {
    0          
    0          
151 0           $self->{$k} = new Biblio::ILL::ISO::ISODate();
152 0           $self->{$k}->from_asn($href->{$k});
153            
154             } elsif ($k =~ /^hold-placed-medium-type$/) {
155 0           $self->{$k} = new Biblio::ILL::ISO::MediumType();
156 0           $self->{$k}->from_asn($href->{$k});
157              
158             } elsif ($k =~ /^locations$/) {
159 0           $self->{$k} = new Biblio::ILL::ISO::LocationInfoSequence();
160 0           $self->{$k}->from_asn($href->{$k});
161              
162             } else {
163 0           croak "invalid " . ref($self) . " element: [$k]";
164             }
165              
166             }
167 0           return $self;
168             }
169              
170             =head1 SEE ALSO
171              
172             See the README for system design notes.
173             See the parent class(es) for other available methods.
174              
175             For more information on Interlibrary Loan standards (ISO 10160/10161),
176             a good place to start is:
177              
178             http://www.nlc-bnc.ca/iso/ill/main.htm
179              
180             =cut
181              
182             =head1 AUTHOR
183              
184             David Christensen,
185              
186             =cut
187              
188              
189             =head1 COPYRIGHT AND LICENSE
190              
191             Copyright 2003 by David Christensen
192              
193             This library is free software; you can redistribute it and/or modify it
194             under the same terms as Perl itself.
195              
196             =cut
197              
198             1;