File Coverage

blib/lib/Finance/AMEX/Transaction/EPPRC/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::EPPRC::Base 0.005;
2              
3 9     9   61 use strict;
  9         19  
  9         222  
4 9     9   35 use warnings;
  9         15  
  9         1722  
5              
6             # ABSTRACT: Parse AMEX Chargeback Notification Files (EPPRC) Base methods
7              
8             sub new {
9 1131     1131 1 3016 my ($class, %props) = @_;
10 1131         3098 my $self = bless {_line => $props{line}}, $class;
11 1131         3314 return $self;
12             }
13              
14             sub line {
15 0     0 1 0 my ($self) = @_;
16 0         0 return $self->{_line};
17             }
18              
19             sub _get_column {
20 28492     28492   53555 my ($self, $field) = @_;
21 28492         57383 my $map = $self->field_map->{$field};
22              
23             # if the line is not long enough to handle the start of the field,
24             # it is an optional field that we don't have
25 28492 100       163264 if (length($self->{_line}) < $map->[0]) {
26 24         153 return '';
27             }
28              
29 28468         65224 my $ret = substr($self->{_line}, $map->[0] - 1, $map->[1]);
30 28468         91560 $ret =~ s{\s+\z}{}xsm;
31 28468         164661 return $ret;
32             }
33              
34             1;
35              
36             __END__