File Coverage

blib/lib/Biblio/ILL/ISO/PersonOrInstitutionSymbol.pm
Criterion Covered Total %
statement 20 38 52.6
branch 2 10 20.0
condition 1 3 33.3
subroutine 6 9 66.6
pod 5 5 100.0
total 34 65 52.3


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::PersonOrInstitutionSymbol;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::PersonOrInstitutionSymbol
6              
7             =cut
8              
9 4     4   24 use Biblio::ILL::ISO::ILLASNtype;
  4         8  
  4         96  
10 4     4   22 use Biblio::ILL::ISO::ILLString;
  4         17  
  4         108  
11              
12 4     4   18 use Carp;
  4         7  
  4         427  
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::PersonOrInstitutionSymbol 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::SystemId
37              
38             =cut
39              
40 4     4   2083 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
41              
42             =head1 FROM THE ASN DEFINITION
43            
44             Person-Or-Institution-Symbol ::= CHOICE {
45             person-symbol [0] ILL-String,
46             institution-symbol [1] ILL-String
47             }
48              
49             =cut
50              
51             =head1 METHODS
52              
53             =cut
54             #---------------------------------------------------------------
55             #
56             #---------------------------------------------------------------
57             =head1
58              
59             =head2 new( [$institution_symbol] )
60              
61             Creates a new PersonOrInstitutionSymbol object.
62             Expects either no paramaters, or
63             an institution-symbol (text string).
64              
65             =cut
66             sub new {
67 60     60 1 92 my $class = shift;
68 60         84 my $self = {};
69              
70 60 100       142 if (@_) {
71 57         167 $self->{"institution-symbol"} = new Biblio::ILL::ISO::ILLString(shift);
72             }
73 60   33     254 bless($self, ref($class) || $class);
74 60         678 return ($self);
75             }
76              
77              
78             #---------------------------------------------------------------
79             #
80             #---------------------------------------------------------------
81             =head1
82              
83             =head2 as_string( )
84              
85             Returns a stringified representation of the object.
86              
87             =cut
88             sub as_string {
89 0     0 1 0 my $self = shift;
90              
91 0 0       0 return $self->{"person-symbol"}->as_string() if ($self->{"person-symbol"});
92 0 0       0 return $self->{"institution-symbol"}->as_string() if ($self->{"institution-symbol"});
93 0         0 return "";
94             }
95              
96              
97             #---------------------------------------------------------------
98             #
99             #---------------------------------------------------------------
100             =head1
101              
102             =head2 from_asn($href)
103              
104             Given a properly formatted hash, builds the object.
105              
106             =cut
107             sub from_asn {
108 0     0 1 0 my $self = shift;
109 0         0 my $href = shift;
110              
111 0         0 foreach my $k (keys %$href) {
112             #print ref($self) . "...$k\n";
113              
114 0 0       0 if ($k =~ /^person-symbol$/) {
    0          
115 0         0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
116 0         0 $self->{$k}->from_asn($href->{$k});
117              
118             } elsif ($k =~ /^institution-symbol$/) {
119 0         0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
120 0         0 $self->{$k}->from_asn($href->{$k});
121              
122             } else {
123 0         0 croak "invalid " . ref($self) . " element: [$k]";
124             }
125              
126             }
127 0         0 return $self;
128             }
129              
130             #---------------------------------------------------------------
131             #
132             #---------------------------------------------------------------
133             =head1
134              
135             =head2 set_person_symbol( $s )
136              
137             Sets the object's person-symbol.
138             Expects a text string.
139              
140             =cut
141             sub set_person_symbol {
142 0     0 1 0 my $self = shift;
143 0         0 my ($s) = @_;
144              
145 0         0 $self->{"person-symbol"} = new Biblio::ILL::ISO::ILLString($s);
146              
147 0         0 return;
148             }
149              
150             #---------------------------------------------------------------
151             #
152             #---------------------------------------------------------------
153             =head1
154              
155             =head2 set_institution_symbol( $s )
156              
157             Sets the object's institution-symbol.
158             Expects a text string.
159              
160             =cut
161             sub set_institution_symbol {
162 3     3 1 7 my $self = shift;
163 3         6 my ($s) = @_;
164              
165 3         13 $self->{"institution-symbol"} = new Biblio::ILL::ISO::ILLString($s);
166              
167 3         6 return;
168             }
169              
170              
171             1;