File Coverage

blib/lib/Text/NASA_Ames/FFI1020.pm
Criterion Covered Total %
statement 45 56 80.3
branch 11 18 61.1
condition 2 6 33.3
subroutine 6 6 100.0
pod 1 1 100.0
total 65 87 74.7


line stmt bran cond sub pod time code
1             package Text::NASA_Ames::FFI1020;
2 1     1   65718 use base qw(Text::NASA_Ames);
  1         5  
  1         748  
3 1     1   9 use Carp;
  1         4  
  1         76  
4              
5 1     1   35 use 5.00600;
  1         4  
  1         39  
6 1     1   6 use strict;
  1         2  
  1         786  
7              
8             our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf " %d." . "%02d" x $#r, @r };
9              
10              
11             =head1 NAME
12              
13             Text::NASA_Ames::FFI1020 - Implementation of FFI1020 NASA_Ames format
14              
15             =head1 SYNOPSIS
16              
17              
18             =head1 DESCRIPTION
19              
20             This class should normally not be called directly but through the
21             L class indirectly.
22              
23             =head1 PUBLIC METHODS
24              
25             =over 4
26              
27             =item new (Text::NASA_Ames-object || options for new NASA_Ames)
28              
29             parses the (rest of the) header (body and comments)
30              
31             =cut
32              
33             sub new {
34 4     4 1 7 my ($class, $fileObj) = @_;
35 4   33     24 $class = ref $class || $class;
36 4 50 33     28 if (! (ref $fileObj && (ref($fileObj) eq 'Text::NASA_Ames'))) {
37 0         0 return new Text::NASA_Ames($fileObj);
38             }
39 4         8 my $self = $fileObj;
40 4         10 bless $self, $class;
41              
42 4         19 $self->_parseList('dX', $self->nIV);
43 4 50       59 unless ($self->dX()->[0]) {
44 0         0 $self->_carp("dX must be defined and != 0 for ".ref $self);
45 0         0 return;
46             }
47 4         49 $self->_parseList('nVPM', $self->nIV);
48 4 50       47 unless ($self->nVPM()->[0] > 0) {
49 0         0 $self->_carp("nVPM must be > 0 for ".ref $self . " was: ".
50             $self->nVPM()->[0]);
51 0         0 return;
52             }
53 4         50 $self->_parseLines('xName', $self->nIV);
54 4         53 $self->_parseVDeclaration;
55 4         68 $self->_parseAuxDeclaration;
56 4         57 $self->_parseTailHeader;
57              
58 4         61 return $self;
59             }
60              
61             sub _refillBuffer {
62 6     6   8 my $self = shift;
63              
64 6         17 my $line = $self->nextLine;
65 6 100       19 return unless defined $line;
66              
67 4         19 my ($x, @a) = split ' ', $line;
68 4 50       15 if (@a != $self->nAuxV) {
69 0         0 $self->_carp("not enough elements for Aux, expected ".
70             $self->nAuxV() . ", got ". scalar @a);
71 0         0 return;
72             }
73 4 100       50 $self->_cleanAndScaleVals($self->aMiss, $self->aScal, \@a)
74             if $self->nAuxV > 0;
75              
76 4         23 my @vHelp;
77 4         17 for (my $i = 0; $i < $self->nV; $i++) {
78 16         286 $line = $self->nextLine;
79 16 50       41 unless ($line) {
80 0         0 $self->_carp("not enough elements for V".
81             " in row ". $self->currentLine);
82 0         0 return;
83             }
84            
85 16 50       30 return unless defined $line;
86 16         87 my @vi = split ' ', $line;
87 16 50       51 if (@vi != $self->nVPM()->[0]) {
88 0         0 $self->_carp("not enough elements for nVPM, expected ".
89             $self->nVPM()->[0] . ", got ". scalar @vi .
90             " in row ". $self->currentLine);
91 0         0 return;
92             }
93             # transposing for faster access
94 16         165 for (my $j = 0; $j < $self->nVPM()->[0]; $j++) {
95 160         1810 $vHelp[$j][$i] = $vi[$j];
96             }
97             }
98              
99 4         88 for (my $j = 0; $j < $self->nVPM()->[0]; $j++) {
100 40         392 $self->_cleanAndScaleVals($self->vMiss, $self->vScal, $vHelp[$j]);
101 40         53 push @{ $self->dataBuffer },
  40         100  
102             new Text::NASA_Ames::DataEntry({X => [ $x + ($j * $self->dX()->[0]) ],
103             V => $vHelp[$j],
104             A => \@a});
105             }
106             }
107              
108             1;
109             __END__