lib/Biblio/ILL/ISO/Amount.pm

filter: Statementstmt 57.5% 23 / 40 Branchbran 27.2% 6 / 22 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod 100% 3 / 3 totaltotal 49.3% 38 / 77 CC 14 SCAR 26.7
CC
14
Cov
46%
set
30.0
from_asn
20.0
new
7.8
CRAP 14.4
« lib/Biblio/ILL/ISO/ClientId.pm ↑ Summary lib/Biblio/ILL/ISO/EstimateResults.pm »
1 package Biblio::ILL::ISO::Amount;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::Amount
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::AmountString;
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.02
17  
18 =cut
19  
20 4 our $VERSION = '0.02';
21 #---------------------------------------------------------------------------
22 # Mods
23 # 0.02 - 2003.09.07 - fixed the POD
24 # 0.01 - 2003.07.15 - original version
25 #---------------------------------------------------------------------------
26  
27 =head1 DESCRIPTION
28  
29 Biblio::ILL::ISO::Amount is a derivation of Biblio::ILL::ISO::ILLASNtype.
30  
31 =head1 USES
32  
33 Biblio::ILL::ISO::AmountString
34  
35 =head1 USED IN
36  
37 Biblio::ILL::ISO::CostInfoType
38 Biblio::ILL::ISO::SupplyDetails
39  
40 =cut
41  
42 4 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 =head1 FROM THE ASN DEFINITION
45
46 Amount ::= SEQUENCE {
47 currency-code [0] IMPLICIT PrintableString OPTIONAL, --(SIZE (3))
48 -- values defined in ISO 4217-1981
49 monetary-value [1] IMPLICIT AmountString -- (SIZE (1..10))
50 }
51  
52 =cut
53  
54 =head1 METHODS
55  
56 =cut
57 #---------------------------------------------------------------
58 #
59 #---------------------------------------------------------------
60 =head1
61  
62 =head2 new([$amount_string [, $currency_code] ])
63  
64 Creates a new Amount object. Expects either no parameters, or
65 a valid Biblio::ILL::ISO::AmountString and (optionally) a 3-character
66 string indicating the currency code.
67  
68 =cut
69 10 ▶sub new {
Subroutine new: called CC=7 SCAR=20.5
Pod documented
70 10 my $class = shift;
71 10 my $self = {};
72  
73 10 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 10 0 10
74 10 my ($monetary_value, $currency_code) = @_;
75
76 10 ▶ croak "Missing monetary value" unless ($monetary_value);
Branch: 1 branch
BranchTrueFalseTotal
unless $monetary_value 0 10 10
77 10 $self->{"monetary-value"} = new Biblio::ILL::ISO::AmountString($monetary_value);
78
79 10 ▶ if ($currency_code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currency_code) 1 9 10
80 # currency code is optional
81 1 ▶ croak "Invalid currency code" unless ((length $currency_code) == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless length $currency_code == 3 0 1 1
82 1 ▶ $self->{"currency-code"} = $currency_code if ($currency_code);
Branch: 1 branch
BranchTrueFalseTotal
if $currency_code 1 0 1
83 }
84 }
85  
86 10 ▶ bless($self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0100
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
87 10 return ($self);
88 }
89  
90  
91 #---------------------------------------------------------------
92 #
93 #---------------------------------------------------------------
94 =head1
95  
96 =head2 set($amount_string [, $currence_code])
97  
98 Sets the object's monetary-value (a Biblio::ILL::ISO::AmountString) and (optionally)
99 currency-code (a 3-character text string).
100  
101 =cut
102 0 ▶sub set {
Subroutine set: not called CC=5 SCAR=34.0
Pod documented
103 0 my $self = shift;
104 0 my ($monetary_value, $currency_code) = @_;
105  
106 0 ▶ croak "Missing monetary value" unless ($monetary_value);
Branch: 1 branch
BranchTrueFalseTotal
unless $monetary_value 0 0 0
107 0 $self->{"monetary-value"} = new Biblio::ILL::ISO::AmountString($monetary_value);
108  
109 0 ▶ if ($currency_code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currency_code) 0 0 0
110 # currency code is optional
111 0 ▶ croak "Invalid currency code" unless ((length $currency_code) == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless length $currency_code == 3 0 0 0
112 0 ▶ $self->{"currency-code"} = $currency_code if ($currency_code);
Branch: 1 branch
BranchTrueFalseTotal
if $currency_code 0 0 0
113 }
114  
115 0 return;
116 }
117  
118  
119 #---------------------------------------------------------------
120 #
121 #---------------------------------------------------------------
122 =head1
123  
124 =head2 from_asn($href)
125  
126 Given a properly formatted hash, builds the object.
127  
128 =cut
129 0 ▶sub from_asn {
Subroutine from_asn: not called CC=4 SCAR=30.0
Pod documented
130 0 my $self = shift;
131 0 my $href = shift;
132  
133 0 foreach my $k (keys %$href) {
134 #print ref($self) . "...$k\n";
135  
136 0 ▶ if ($k =~ /^monetary-value$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ /^monetary-value$/) { } 0 0 0
elsif ($k =~ /^currency-code$/) { } 0 0 0
137 0 $self->{$k} = new Biblio::ILL::ISO::AmountString();
138 0 $self->{$k}->from_asn($href->{$k});
139
140 } elsif ($k =~ /^currency-code$/) {
141 0 $self->{$k} = $href->{$k};
142
143 } else {
144 0 croak "invalid " . ref($self) . " element: [$k]";
145 }
146  
147 }
148 0 return $self;
149 }
150  
151 =head1 SEE ALSO
152  
153 See the README for system design notes.
154  
155 For more information on Interlibrary Loan standards (ISO 10160/10161),
156 a good place to start is:
157  
158 http://www.nlc-bnc.ca/iso/ill/main.htm
159  
160 =cut
161  
162 =head1 AUTHOR
163  
164 David Christensen, <DChristensenSPAMLESS@westman.wave.ca>
165  
166 =cut
167  
168  
169 =head1 COPYRIGHT AND LICENSE
170  
171 Copyright 2003 by David Christensen
172  
173 This library is free software; you can redistribute it and/or modify it
174 under the same terms as Perl itself.
175  
176 =cut
177 4 1;
« lib/Biblio/ILL/ISO/ClientId.pm ↑ Summary lib/Biblio/ILL/ISO/EstimateResults.pm »