File Coverage

blib/lib/Biblio/ILL/ISO/NameOfPersonOrInstitution.pm
Criterion Covered Total %
statement 24 35 68.5
branch 2 8 25.0
condition 1 6 16.6
subroutine 7 9 77.7
pod 5 5 100.0
total 39 63 61.9


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::NameOfPersonOrInstitution;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::NameOfPersonOrInstitution
6              
7             =cut
8              
9 4     4   24 use Biblio::ILL::ISO::ILLASNtype;
  4         7  
  4         104  
10 4     4   19 use Biblio::ILL::ISO::ILLString;
  4         8  
  4         77  
11              
12 4     4   22 use Carp;
  4         6  
  4         401  
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::NameOfPersonOrInstitution 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::PostalAddress
37             Biblio::ILL::ISO::SystemId
38              
39             =cut
40              
41 4     4   1916 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
42              
43             =head1 FROM THE ASN DEFINITION
44            
45             Name-Of-Person-Or-Institution ::= CHOICE {
46             name-of-person [0] ILL-String,
47             name-of-institution [1] ILL-String
48             }
49              
50             =cut
51              
52             =head1 METHODS
53              
54             =cut
55              
56             #---------------------------------------------------------------
57             #
58             #---------------------------------------------------------------
59             =head1
60              
61             =head2 new( [$name_of_institution] )
62              
63             Creates a new NameOfPersonOrInstitution object.
64             Expects either no paramaters, or
65             an institution name (text string).
66              
67             =cut
68             sub new {
69 38     38 1 54 my $class = shift;
70 38         61 my $self = {};
71              
72 38 100       79 if (@_) {
73 1         5 $self->{"name-of-institution"} = new Biblio::ILL::ISO::ILLString(shift);
74             }
75 38   33     171 bless($self, ref($class) || $class);
76 38         153 return ($self);
77             }
78              
79              
80             #---------------------------------------------------------------
81             #
82             #---------------------------------------------------------------
83             =head1
84              
85             =head2 as_string( )
86              
87             Returns a stringified representation of the object.
88              
89             =cut
90             sub as_string {
91 0     0 1 0 my $self = shift;
92              
93 0 0       0 return $self->{"name-of-person"}->as_string() if ($self->{"name-of-person"});
94 0 0       0 return $self->{"name-of-institution"}->as_string() if ($self->{"name-of-institution"});
95 0         0 return "";
96             }
97              
98              
99             #---------------------------------------------------------------
100             #
101             #---------------------------------------------------------------
102             =head1
103              
104             =head2 set_person_name( $s )
105              
106             Sets the object's name-of-person.
107             Expects a text string.
108              
109             =cut
110             sub set_person_name {
111 26     26 1 38 my $self = shift;
112 26         36 my ($s) = @_;
113              
114 26         74 $self->{"name-of-person"} = new Biblio::ILL::ISO::ILLString($s);
115              
116 26         50 return;
117             }
118              
119             #---------------------------------------------------------------
120             #
121             #---------------------------------------------------------------
122             =head1
123              
124             =head2 set_institution_name( $s )
125              
126             Sets the object's name-of-institution.
127             Expects a text string.
128              
129             =cut
130             sub set_institution_name {
131 11     11 1 17 my $self = shift;
132 11         18 my ($s) = @_;
133              
134 11         36 $self->{"name-of-institution"} = new Biblio::ILL::ISO::ILLString($s);
135              
136 11         35 return;
137             }
138              
139             #---------------------------------------------------------------
140             #
141             #---------------------------------------------------------------
142             =head1
143              
144             =head2 from_asn($href)
145              
146             Given a properly formatted hash, builds the object.
147              
148             =cut
149             sub from_asn {
150 0     0 1   my $self = shift;
151 0           my $href = shift;
152              
153 0           foreach my $k (keys %$href) {
154              
155 0 0 0       if (($k =~ /^name-of-person$/)
156             || ($k =~ /^name-of-institution$/)
157             ) {
158 0           $self->{$k} = new Biblio::ILL::ISO::ILLString($href->{$k});
159              
160             } else {
161 0           croak "invalid " . ref($self) . "element: [$k]";
162             }
163              
164             }
165 0           return $self;
166             }
167              
168             =head1 SEE ALSO
169              
170             See the README for system design notes.
171             See the parent class(es) for other available methods.
172              
173             For more information on Interlibrary Loan standards (ISO 10160/10161),
174             a good place to start is:
175              
176             http://www.nlc-bnc.ca/iso/ill/main.htm
177              
178             =cut
179              
180             =head1 AUTHOR
181              
182             David Christensen,
183              
184             =cut
185              
186              
187             =head1 COPYRIGHT AND LICENSE
188              
189             Copyright 2003 by David Christensen
190              
191             This library is free software; you can redistribute it and/or modify it
192             under the same terms as Perl itself.
193              
194             =cut
195             1;