File Coverage

blib/lib/Finance/AMEX/Transaction/EPTRN/Base.pm
Criterion Covered Total %
statement 15 18 83.3
branch 1 2 50.0
condition n/a
subroutine 4 5 80.0
pod 2 2 100.0
total 22 27 81.4


line stmt bran cond sub pod time code
1             package Finance::AMEX::Transaction::EPTRN::Base 0.005;
2              
3 9     9   63 use strict;
  9         18  
  9         212  
4 9     9   36 use warnings;
  9         13  
  9         1696  
5              
6             # ABSTRACT: Parse AMEX Transaction/Invoice Level Reconciliation (EPTRN)
7              
8             sub new {
9 5     5 1 12 my ($class, %props) = @_;
10 5         15 my $self = bless {_line => $props{line}}, $class;
11              
12 5         13 return $self;
13             }
14              
15             sub line {
16 0     0 1 0 my ($self) = @_;
17 0         0 return $self->{_line};
18             }
19              
20             sub _get_column {
21 82     82   169 my ($self, $field) = @_;
22 82         183 my $map = $self->field_map->{$field};
23              
24             # if the line is not long enough to handle the start of the field,
25             # it is an optional field that we don't have
26 82 50       403 if (length($self->{_line}) < $map->[0]) {
27 0         0 return '';
28             }
29              
30 82         176 my $ret = substr($self->{_line}, $map->[0] - 1, $map->[1]);
31 82         250 $ret =~ s{\s+\z}{}xsm;
32 82         429 return $ret;
33             }
34              
35             1;
36              
37             __END__