File Coverage

blib/lib/Biblio/ILL/ISO/ResponderOptionalMessageType.pm
Criterion Covered Total %
statement 27 49 55.1
branch 5 24 20.8
condition 1 6 16.6
subroutine 6 8 75.0
pod 2 3 66.6
total 41 90 45.5


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::ResponderOptionalMessageType;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::ResponderOptionalMessageType
6              
7             =cut
8              
9 4     4   641 use Biblio::ILL::ISO::ILLASNtype;
  4         10  
  4         148  
10 4     4   2500 use Biblio::ILL::ISO::ResponderRECEIVED;
  4         11  
  4         125  
11 4     4   4426 use Biblio::ILL::ISO::ResponderRETURNED;
  4         12  
  4         124  
12              
13 4     4   26 use Carp;
  4         10  
  4         342  
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.07.27 - original version
25             #---------------------------------------------------------------------------
26              
27             =head1 DESCRIPTION
28              
29             Biblio::ILL::ISO::ResponderOptionalMessageType is a derivation of Biblio::ILL::ISO::ILLASNtype.
30              
31             =head1 USES
32              
33             Biblio::ILL::ISO::ResponderRECEIVED
34             Biblio::ILL::ISO::ResponderRETURNED
35              
36             =head1 USED IN
37              
38             Biblio::ILL::ISO::Answer
39             Biblio::ILL::ISO::Shipped
40              
41             =cut
42              
43 4     4   2358 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
44              
45             =head1 FROM THE ASN DEFINITION
46             # From the ASN
47             #
48             #Responder-Optional-Messages-Type ::= EXPLICIT SEQUENCE {
49             # can-send-SHIPPED [0] IMPLICIT BOOLEAN,
50             # can-send-CHECKED-IN [1] IMPLICIT BOOLEAN,
51             # responder-RECEIVED [2] IMPLICIT ENUMERATED {
52             # requires (1),
53             # desires (2),
54             # neither (3)
55             # }
56             # responder-RETURNED [3] IMPLICIT ENUMERATED {
57             # requires (1),
58             # desires (2),
59             # neither (3)
60             # }
61             # }
62             #
63             =cut
64              
65             =head1 METHODS
66              
67             =cut
68              
69             #---------------------------------------------------------------
70             #
71             #---------------------------------------------------------------
72             =head1
73              
74             =head2 new( $can_send_shipped, $can_send_checked_in, $responder_received, $responder_returned )
75              
76             Creates a new ResponderOptionalMessageType object.
77             Expects a can-send-SHIPPED flag ( 0|1 ),
78             a can-send-CHECKED-IN flag ( 0|1 ),
79             a responder-RECEIVED string (a valid Biblio::ILL::ISO::ResponderRECEIVED enumerated value), and
80             a responder-RETURNED string (a valid Biblio::ILL::ISO::ResponderRETURNED enumerated value).
81              
82             =cut
83             sub new {
84 3     3 1 23 my $class = shift;
85 3         5 my $self = {};
86              
87 3 50       9 if (@_) {
88 3         7 my ($bshipped, $bcheckedin, $sreceived, $sreturned) = @_;
89            
90 3 50       8 croak "missing ResponderOptionalMessageType parameter can-send-SHIPPED" unless $bshipped;
91 3 50       8 croak "missing ResponderOptionalMessageType parameter can-send-CHECKED-IN" unless $bcheckedin;
92 3 50       11 croak "missing ResponderOptionalMessageType parameter responder-RECEIVED" unless $sreceived;
93 3 50       6 croak "missing ResponderOptionalMessageType parameter responder-RETURNED" unless $sreturned;
94              
95 3         8 $self->{"can-send-SHIPPED"} = $bshipped;
96 3         4 $self->{"can-send-CHECKED-IN"} = $bcheckedin;
97 3         21 $self->{"responder-RECEIVED"} = new Biblio::ILL::ISO::ResponderRECEIVED($sreceived);
98 3         21 $self->{"responder-RETURNED"} = new Biblio::ILL::ISO::ResponderRETURNED($sreturned);
99             }
100              
101 3   33     15 bless($self, ref($class) || $class);
102 3         8 return ($self);
103             }
104              
105              
106             #---------------------------------------------------------------
107             #
108             #---------------------------------------------------------------
109             =head1
110              
111             =head2 new( $can_send_shipped, $can_send_checked_in, $responder_received, $responder_returned )
112              
113             Sets the object's can-send-SHIPPED flag ( 0|1 ),
114             can-send-CHECKED-IN flag ( 0|1 ),
115             responder-RECEIVED string (a valid Biblio::ILL::ISO::ResponderRECEIVED enumerated value), and
116             responder-RETURNED string (a valid Biblio::ILL::ISO::ResponderRETURNED enumerated value).
117              
118             =cut
119             sub set {
120 0     0 0   my $self = shift;
121 0           my ($bshipped, $bcheckedin, $sreceived, $sreturned) = @_;
122            
123 0 0         croak "missing ResponderOptionalMessageType parameter can-send-SHIPPED" unless $bshipped;
124 0 0         croak "missing ResponderOptionalMessageType parameter can-send-CHECKED-IN" unless $bcheckedin;
125 0 0         croak "missing ResponderOptionalMessageType parameter responder-RECEIVED" unless $sreceived;
126 0 0         croak "missing ResponderOptionalMessageType parameter responder-RETURNED" unless $sreturned;
127              
128 0           $self->{"can-send-SHIPPED"} = $bshipped;
129 0           $self->{"can-send-CHECKED-IN"} = $bcheckedin;
130 0           $self->{"responder-RECEIVED"} = new Biblio::ILL::ISO::ResponderRECEIVED($sreceived);
131 0           $self->{"responder-RETURNED"} = new Biblio::ILL::ISO::ResponderRETURNED($sreturned);
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 =~ /^can-send-SHIPPED$/)
    0          
    0          
154             || ($k =~ /^can-send-CHECKED-IN$/)
155             ) {
156 0           $self->{$k} = $href->{$k};
157              
158             } elsif ($k =~ /^responder-RECEIVED$/) {
159 0           $self->{$k} = new Biblio::ILL::ISO::ResponderRECEIVED();
160 0           $self->{$k}->from_asn($href->{$k});
161              
162             } elsif ($k =~ /^responder-RETURNED$/) {
163 0           $self->{$k} = new Biblio::ILL::ISO::ResponderRETURNED();
164 0           $self->{$k}->from_asn($href->{$k});
165              
166             } else {
167 0           croak "invalid " . ref($self) . " element: [$k]";
168             }
169              
170             }
171 0           return $self;
172             }
173              
174             =head1 SEE ALSO
175              
176             See the README for system design notes.
177             See the parent class(es) for other available methods.
178              
179             For more information on Interlibrary Loan standards (ISO 10160/10161),
180             a good place to start is:
181              
182             http://www.nlc-bnc.ca/iso/ill/main.htm
183              
184             =cut
185              
186             =head1 AUTHOR
187              
188             David Christensen,
189              
190             =cut
191              
192              
193             =head1 COPYRIGHT AND LICENSE
194              
195             Copyright 2003 by David Christensen
196              
197             This library is free software; you can redistribute it and/or modify it
198             under the same terms as Perl itself.
199              
200             =cut
201              
202             1;