File Coverage

blib/lib/Finance/AMEX/Transaction/EPRAW/Base.pm
Criterion Covered Total %
statement 16 18 88.8
branch 2 2 100.0
condition n/a
subroutine 4 5 80.0
pod 2 2 100.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package Finance::AMEX::Transaction::EPRAW::Base 0.005;
2              
3 9     9   62 use strict;
  9         13  
  9         211  
4 9     9   36 use warnings;
  9         16  
  9         1687  
5              
6             # ABSTRACT: Parse AMEX Chargeback Notification Files (EPRAW) Base methods
7              
8             sub new {
9 40     40 1 104 my ($class, %props) = @_;
10 40         96 my $self = bless {_line => $props{line}}, $class;
11              
12 40         115 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 767     767   1481 my ($self, $field) = @_;
22 767         1767 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 767 100       4010 if (length($self->{_line}) < $map->[0]) {
27 1         7 return '';
28             }
29              
30 766         1715 my $ret = substr($self->{_line}, $map->[0] - 1, $map->[1]);
31 766         2238 $ret =~ s{\s+\z}{}xsm;
32 766         4319 return $ret;
33             }
34              
35             1;
36              
37             __END__