lib/Biblio/ILL/ISO/NameOfPersonOrInstitution.pm

filter: Statementstmt 70.2% 26 / 37 Branchbran 25.0% 2 / 8 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 100% 5 / 5 totaltotal 59.4% 41 / 69 CC 8 SCAR 21.0
CC
8
Cov
57%
from_asn
20.0
as_string
12.0
new
3.1
CRAP 8.2
« lib/Biblio/ILL/ISO/PersonOrInstitutionSymbol.pm ↑ Summary lib/Biblio/ILL/ISO/DeliveryAddress.pm »
1 package Biblio::ILL::ISO::NameOfPersonOrInstitution;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::NameOfPersonOrInstitution
6  
7 =cut
8  
9 4 ▶use Biblio::ILL::ISO::ILLASNtype;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Biblio::ILL::ISO::ILLString;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =head1 VERSION
15  
16 Version 0.01
17  
18 =cut
19  
20 4 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 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
Subroutine BEGIN: called CC=1 SCAR=0.0
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 38 ▶sub new {
Subroutine new: called CC=3 SCAR=11.2
Pod documented
69 38 my $class = shift;
70 38 my $self = {};
71  
72 38 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 37 38
73 1 $self->{"name-of-institution"} = new Biblio::ILL::ISO::ILLString(shift);
74 }
75 38 ▶ bless($self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0380
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
76 38 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 0 ▶sub as_string {
Subroutine as_string: not called CC=3 SCAR=24.8
Pod documented
91 0 my $self = shift;
92  
93 0 ▶ return $self->{"name-of-person"}->as_string() if ($self->{"name-of-person"});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"name-of-person"} 0 0 0
94 0 ▶ return $self->{"name-of-institution"}->as_string() if ($self->{"name-of-institution"});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"name-of-institution"} 0 0 0
95 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 26 ▶sub set_person_name {
Subroutine set_person_name: called CC=1 SCAR=0.0
Pod documented
111 26 my $self = shift;
112 26 my ($s) = @_;
113  
114 26 $self->{"name-of-person"} = new Biblio::ILL::ISO::ILLString($s);
115  
116 26 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 11 ▶sub set_institution_name {
Subroutine set_institution_name: called CC=1 SCAR=0.0
Pod documented
131 11 my $self = shift;
132 11 my ($s) = @_;
133  
134 11 $self->{"name-of-institution"} = new Biblio::ILL::ISO::ILLString($s);
135  
136 11 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 0 ▶sub from_asn {
Subroutine from_asn: not called CC=4 SCAR=30.0
Pod documented
150 0 my $self = shift;
151 0 my $href = shift;
152  
153 0 foreach my $k (keys %$href) {
154  
155 0 ▶ if (($k =~ /^name-of-person$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^name-of-person$/ or $k =~ /^name-of-institution$/) { } 0 0 0
Condition0%0/3
$k =~ /^name-of-person$/ or $k =~ /^name-of-institution$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$k =~ /^name-of-person$/ or $k =~ /^name-of-institution$/
$k =~ /^name-of-person$/ $k =~ /^name-of-institution$/
Truth table0%0/3
A or B
A= $k =~ /^name-of-person$/B= $k =~ /^name-of-institution$/
ABresult
1X1
011
000
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, <DChristensenSPAMLESS@westman.wave.ca>
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 4 1;
« lib/Biblio/ILL/ISO/PersonOrInstitutionSymbol.pm ↑ Summary lib/Biblio/ILL/ISO/DeliveryAddress.pm »