File Coverage

blib/lib/Biblio/ILL/ISO/ClientId.pm
Criterion Covered Total %
statement 19 33 57.5
branch 4 16 25.0
condition 1 9 11.1
subroutine 5 7 71.4
pod 3 3 100.0
total 32 68 47.0


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::ClientId;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::ClientId
6              
7             =cut
8              
9 4     4   703 use Biblio::ILL::ISO::ILLASNtype;
  4         9  
  4         129  
10 4     4   24 use Biblio::ILL::ISO::ILLString;
  4         7  
  4         84  
11              
12 4     4   23 use Carp;
  4         9  
  4         434  
13              
14             =head1 VERSION
15              
16             Version 0.01
17              
18             =cut
19             our $VERSION = '0.01';
20             #---------------------------------------------------------------------------
21             # Mods
22             # 0.01 - 2003.07.15 - original version
23             #---------------------------------------------------------------------------
24              
25             =head1 DESCRIPTION
26              
27             Biblio::ILL::ISO::ClientId is a derivation of Biblio::ILL::ISO::ILLASNtype.
28              
29             =head1 USES
30              
31             Biblio::ILL::ISO::ILLString
32              
33             =head1 USED IN
34              
35             Biblio::ILL::ISO::Request
36             Biblio::ILL::ISO::Shipped
37              
38             =cut
39              
40 4     4   2184 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
41              
42             =head1 FROM THE ASN DEFINITION
43            
44             Client-Id ::= SEQUENCE {
45             client-name [0] ILL-String OPTIONAL,
46             client-status [1] ILL-String OPTIONAL,
47             client-identifier [2] ILL-String OPTIONAL
48             }
49              
50             =cut
51              
52             =head1 METHODS
53              
54             =cut
55              
56             #---------------------------------------------------------------
57             #
58             #---------------------------------------------------------------
59             =head1
60              
61             =head2 new( [ [$name], [$status], [$id] ] )
62              
63             Creates a new ClientId object. Expects either no parameters, or
64             1, 2, or 3 text strings. Pass in empty strings ("") as placeholders.
65              
66             =cut
67             sub new {
68 3     3 1 27 my $class = shift;
69 3         14 my $self = {};
70              
71 3 50       11 if (@_) {
72 3         8 my ($name, $status, $identifier) = @_;
73            
74 3 50       16 $self->{"client-name"} = new Biblio::ILL::ISO::ILLString($name) if ($name);
75 3 50       26 $self->{"client-status"} = new Biblio::ILL::ISO::ILLString($status) if ($status);
76 3 50       17 $self->{"client-identifier"} = new Biblio::ILL::ISO::ILLString($identifier) if ($identifier);
77             }
78              
79 3   33     27 bless($self, ref($class) || $class);
80 3         10 return ($self);
81             }
82              
83              
84             #---------------------------------------------------------------
85             #
86             #---------------------------------------------------------------
87             =head1
88              
89             =head2 set(( [ [$name], [$status], [$id] ] )
90              
91             Sets the object's client-name, client-status, and/or client-identifier.
92             Expects 1, 2, or 3 text strings. Pass in empty strings ("") as placeholders.
93              
94             =cut
95             sub set {
96 0     0 1   my $self = shift;
97 0           my ($name, $status, $identifier) = @_;
98            
99 0 0         $self->{"client-name"} = new Biblio::ILL::ISO::ILLString($name) if ($name);
100 0 0         $self->{"client-status"} = new Biblio::ILL::ISO::ILLString($status) if ($status);
101 0 0         $self->{"client-identifier"} = new Biblio::ILL::ISO::ILLString($identifier) if ($identifier);
102              
103 0           return;
104             }
105              
106             #---------------------------------------------------------------
107             #
108             #---------------------------------------------------------------
109             =head1
110              
111             =head2 from_asn($href)
112              
113             Given a properly formatted hash, builds the object.
114              
115             =cut
116             sub from_asn {
117 0     0 1   my $self = shift;
118 0           my $href = shift;
119              
120 0           foreach my $k (keys %$href) {
121             #print ref($self) . "...$k\n";
122              
123 0 0 0       if (($k =~ /^client-name$/)
      0        
124             || ($k =~ /^client-status$/)
125             || ($k =~ /^client-identifier$/)
126             ) {
127 0           $self->{$k} = new Biblio::ILL::ISO::ILLString();
128 0           $self->{$k}->from_asn($href->{$k});
129            
130             } else {
131 0           croak "invalid " . ref($self) . " element: [$k]";
132             }
133              
134             }
135 0           return $self;
136             }
137              
138             =head1 SEE ALSO
139              
140             See the README for system design notes.
141             See the parent class(es) for other available methods.
142              
143             For more information on Interlibrary Loan standards (ISO 10160/10161),
144             a good place to start is:
145              
146             http://www.nlc-bnc.ca/iso/ill/main.htm
147              
148             =cut
149              
150             =head1 AUTHOR
151              
152             David Christensen,
153              
154             =cut
155              
156              
157             =head1 COPYRIGHT AND LICENSE
158              
159             Copyright 2003 by David Christensen
160              
161             This library is free software; you can redistribute it and/or modify it
162             under the same terms as Perl itself.
163              
164             =cut
165              
166             1;