File Coverage

blib/lib/Biblio/ILL/ISO/EstimateResults.pm
Criterion Covered Total %
statement 24 46 52.1
branch 5 22 22.7
condition 1 3 33.3
subroutine 6 8 75.0
pod 3 3 100.0
total 39 82 47.5


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