File Coverage

blib/lib/Biblio/ILL/ISO/DateDue.pm
Criterion Covered Total %
statement 23 38 60.5
branch 3 14 21.4
condition 1 3 33.3
subroutine 6 8 75.0
pod 3 3 100.0
total 36 66 54.5


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