File Coverage

blib/lib/Biblio/ILL/ISO/ISODate.pm
Criterion Covered Total %
statement 21 31 67.7
branch 3 10 30.0
condition 1 3 33.3
subroutine 6 9 66.6
pod 4 5 80.0
total 35 58 60.3


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::ISODate;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::ISODate
6              
7             =cut
8              
9 4     4   23 use Biblio::ILL::ISO::ILLASNtype;
  4         6  
  4         118  
10 4     4   22 use Biblio::ILL::ISO::ILLString;
  4         9  
  4         81  
11              
12 4     4   22 use Carp;
  4         7  
  4         430  
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::ISODate is a derivation of Biblio::ILL::ISO::ILLASNtype.
29              
30             =head1 USES
31              
32             Biblio::ILL::ISO::ILLString
33              
34             =head1 USED IN
35              
36             Biblio::ILL::ISO::ConditionalResults
37             Biblio::ILL::ISO::DateDue
38             Biblio::ILL::ISO::DateTime
39             Biblio::ILL::ISO::HistoryReport
40             Biblio::ILL::ISO::HoldPlacedResults
41             Biblio::ILL::ISO::RetryResults
42             Biblio::ILL::ISO::SearchType
43             Biblio::ILL::ISO::WillSupplyResults
44              
45             =cut
46              
47 4     4   1731 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLString
48             Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
49              
50             =head1 FROM THE ASN DEFINITION
51            
52             ISO-Date ::= VisibleString
53             -- conforms to ISO 8601
54             -- length = 8
55             -- fixed
56             -- YYYYMMDD
57              
58             =cut
59              
60             #
61             # NOTE that an ISO-Date _is_not_ an ILL-String!
62             # ...but I've already got ILLString built, so we'll just
63             # inherit and tweak...
64             #
65              
66             =head1 METHODS
67              
68             =cut
69              
70             #---------------------------------------------------------------
71             #
72             #---------------------------------------------------------------
73             =head1
74              
75             =head2 new( $datestring )
76              
77             Creates a new ISODate object.
78             Expects a properly formatted date string (YYYYMMDD).
79              
80             =cut
81             sub new {
82 67     67 1 97 my $class = shift;
83 67         105 my $self = {};
84              
85 67   33     293 bless($self, ref($class) || $class);
86              
87 67 50       148 if (@_) {
88 67         75 my $s = shift;
89            
90             # could use more error checking
91 67 50       132 croak "Invalid ISODate length: [$s]" if ((length $s) > 8);
92 67 50       164 croak "Invalid ISODate: [$s]" if ($s =~ /\D/);
93 67         213 $self->SUPER::set($s); #invoke parent (ie ILLString) 'set'
94             }
95              
96 67         198 return ($self);
97             }
98              
99              
100             #---------------------------------------------------------------
101             #
102             #---------------------------------------------------------------
103             =head1
104              
105             =head2 new( $datestring )
106              
107             Sets the object's value.
108             Expects a properly formatted date string (YYYYMMDD).
109              
110             =cut
111             sub set {
112 0     0 0 0 my $self = shift;
113 0         0 my $s = shift;
114              
115             # could use more error checking
116 0 0       0 croak "Invalid ISODate length: [$s]" if ((length $s) > 8);
117 0 0       0 croak "Invalid ISODate: [$s]" if ($s =~ /\D/);
118 0         0 $self->SUPER::set($s); #invoke parent (ie ILLString) 'set'
119             }
120              
121              
122             #---------------------------------------------------------------
123             #
124             #---------------------------------------------------------------
125             =head1
126              
127             =head2 as_string( )
128              
129             Returns a stringified representation of the object.
130              
131             =cut
132             sub as_string {
133 0     0 1 0 my $self = shift;
134              
135 0         0 return $self->{"generalstring"};
136             }
137              
138              
139             #---------------------------------------------------------------
140             #
141             #---------------------------------------------------------------
142             =head1
143              
144             =head2 as_pretty_string( )
145              
146             Returns a more-formatted stringified representation of the object.
147              
148             =cut
149             sub as_pretty_string {
150 0     0 1 0 my $self = shift;
151              
152 0         0 print STDERR "##### ISODate as_pretty_string: " . $self->{"generalstring"} . "\n";
153              
154 0         0 return $self->{"generalstring"};
155             }
156              
157             #---------------------------------------------------------------
158             # This will return a structure usable by Convert::ASN1
159             #---------------------------------------------------------------
160             =head1
161              
162             =head2 as_asn( )
163              
164             Returns a structure usable by Convert::ASN1. Generally only called
165             from the parent's as_asn() method (or encode() method for top-level
166             message-type objects).
167              
168             =cut
169             sub as_asn {
170 53     53 1 78 my $self = shift;
171              
172             # DC - debug
173             #print " " . $self->{"generalstring"} . "\n";
174              
175 53         222 return $self->{"generalstring"};
176             }
177              
178             =head1 SEE ALSO
179              
180             See the README for system design notes.
181             See the parent class(es) for other available methods.
182              
183             For more information on Interlibrary Loan standards (ISO 10160/10161),
184             a good place to start is:
185              
186             http://www.nlc-bnc.ca/iso/ill/main.htm
187              
188             =cut
189              
190             =head1 AUTHOR
191              
192             David Christensen,
193              
194             =cut
195              
196              
197             =head1 COPYRIGHT AND LICENSE
198              
199             Copyright 2003 by David Christensen
200              
201             This library is free software; you can redistribute it and/or modify it
202             under the same terms as Perl itself.
203              
204             =cut
205              
206             1;