File Coverage

blib/lib/Finnigan/InstrumentLogRecord.pm
Criterion Covered Total %
statement 16 22 72.7
branch n/a
condition n/a
subroutine 6 7 85.7
pod 3 3 100.0
total 25 32 78.1


line stmt bran cond sub pod time code
1             package Finnigan::InstrumentLogRecord;
2              
3 2     2   10 use strict;
  2         3  
  2         77  
4 2     2   12 use warnings FATAL => qw( all );
  2         4  
  2         95  
5             our $VERSION = 0.0206;
6              
7 2     2   10 use Finnigan;
  2         4  
  2         46  
8 2     2   9 use base 'Finnigan::Decoder';
  2         3  
  2         669  
9              
10             sub decode {
11 17     17 1 35 my ($class, $stream, $field_templates) = @_;
12              
13             # This is a sleazy way of decoding this structure. The result will
14             # be a hash whose keys start with the ordinal numbers of elements;
15             # this answers the need to preserve order and to introduce gaps and
16             # section titles commanded by the GenericDataHeader but not present
17             # in the actual record. The field_templates() method of
18             # GenericDataHeader modifies all keys by adding ordinals to them.
19 17         693 my $self = Finnigan::Decoder->read($stream,
20             [
21             '0|time' => ['f<', 'Float32'],
22             @$field_templates # ordered templates from GenericDataHeader
23             ]
24             );
25 17         1847 return bless $self, $class;
26             }
27              
28             sub time {
29 1     1 1 20 shift->{data}->{'0|time'}->{value};
30             }
31              
32             sub fields {
33 0     0 1   my $self = shift;
34 0           map{$self->{data}->{$_}}
  0            
35 0           sort {(split /\|/, $a)[0] <=> (split /\|/, $b)[0]}
36 0           grep {!/0\|time/}
37 0           keys %{$self->{data}};
38             }
39              
40             1;
41             __END__