File Coverage

blib/lib/Biblio/ILL/ISO/ServiceDateTime.pm
Criterion Covered Total %
statement 22 39 56.4
branch 8 24 33.3
condition 1 6 16.6
subroutine 5 7 71.4
pod 2 3 66.6
total 38 79 48.1


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