File Coverage

blib/lib/Biblio/ILL/ISO/ISOTime.pm
Criterion Covered Total %
statement 21 30 70.0
branch 3 10 30.0
condition 1 3 33.3
subroutine 6 9 66.6
pod 4 5 80.0
total 35 57 61.4


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::ISOTime;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::ISOTime
6              
7             =cut
8              
9 4     4   22 use Biblio::ILL::ISO::ILLASNtype;
  4         6  
  4         101  
10 4     4   22 use Biblio::ILL::ISO::ILLString;
  4         7  
  4         98  
11              
12 4     4   8365 use Carp;
  4         29  
  4         550  
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::ISOTime 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::DateTime
37             Biblio::ILL::ISO::ElectronicDeliveryService
38              
39             =cut
40              
41 4     4   8481 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLString
42             Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
43              
44             =head1 FROM THE ASN DEFINITION
45            
46             ISO-Time ::= VisibleString
47             -- conforms to ISO 8601
48             -- length = 6,
49             -- fixed
50             -- HHMMSS
51             -- local time of person or institution invoking service
52              
53             =cut
54              
55             #
56             # NOTE that an ISO-Time _is_not_ an ILL-String!
57             # ...but I've already got ILLString built, so we'll just
58             # inherit and tweak...
59             #
60              
61             =head1 METHODS
62              
63             =cut
64              
65             #---------------------------------------------------------------
66             #
67             #---------------------------------------------------------------
68             =head1
69              
70             =head2 new( $timestring )
71              
72             Creates a new ISODate object.
73             Expects a properly formatted time string (HHMMSS).
74              
75             =cut
76             sub new {
77 44     44 1 53 my $class = shift;
78 44         65 my $self = {};
79              
80 44   33     179 bless($self, ref($class) || $class);
81 44 50       100 if (@_) {
82 44         50 my $s = shift;
83            
84             # could use more error checking
85 44 50       104 croak "Invalid ISOTime length: [$s]" if ((length $s) > 6);
86 44 50       101 croak "Invalid ISOTime: [$s]" if ($s =~ /\D/);
87 44         134 $self->SUPER::set($s); #invoke parent (ie ILLString) 'set'
88             }
89              
90 44         113 return ($self);
91             }
92              
93              
94             #---------------------------------------------------------------
95             #
96             #---------------------------------------------------------------
97             =head1
98              
99             =head2 new( $timestring )
100              
101             Sets the object's value.
102             Expects a properly formatted time string (HHMMSS).
103              
104             =cut
105             sub set {
106 0     0 0 0 my $self = shift;
107 0         0 my $s = shift;
108            
109             # could use more error checking
110 0 0       0 croak "Invalid ISOTime length: [$s]" if ((length $s) > 6);
111 0 0       0 croak "Invalid ISOTime: [$s]" if ($s =~ /\D/);
112 0         0 $self->SUPER::set($s); #invoke parent (ie ILLString) 'set'
113             }
114              
115              
116             #---------------------------------------------------------------
117             #
118             #---------------------------------------------------------------
119             =head1
120              
121             =head2 as_string( )
122              
123             Returns a stringified representation of the object.
124              
125             =cut
126             sub as_string {
127 0     0 1 0 my $self = shift;
128              
129 0         0 return $self->{"generalstring"};
130             }
131              
132              
133             #---------------------------------------------------------------
134             #
135             #---------------------------------------------------------------
136             =head1
137              
138             =head2 as_pretty_string( )
139              
140             Returns a more-formatted stringified representation of the object.
141              
142             =cut
143             sub as_pretty_string {
144 0     0 1 0 my $self = shift;
145              
146 0         0 return $self->{"generalstring"};
147             }
148              
149             #---------------------------------------------------------------
150             # This will return a structure usable by Convert::ASN1
151             #---------------------------------------------------------------
152             =head1
153              
154             =head2 as_asn( )
155              
156             Returns a structure usable by Convert::ASN1. Generally only called
157             from the parent's as_asn() method (or encode() method for top-level
158             message-type objects).
159              
160             =cut
161             sub as_asn {
162 40     40 1 62 my $self = shift;
163              
164             # DC - debug
165             #print " " . $self->{"generalstring"} . "\n";
166              
167 40         161 return $self->{"generalstring"};
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;