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;
2             $Finance::AMEX::Transaction::EPRAW::Base::VERSION = '0.004';
3 8     8   67 use strict;
  8         76  
  8         226  
4 8     8   38 use warnings;
  8         19  
  8         1838  
5              
6             # ABSTRACT: Parse AMEX Chargeback Notification Files (EPRAW) Base methods
7              
8             sub new {
9 40     40 1 146 my ($class, %props) = @_;
10             my $self = bless {
11             _line => $props{line},
12 40         168 }, $class;
13              
14 40         185 return $self;
15             }
16              
17             sub line {
18 0     0 1 0 my ($self) = @_;
19 0         0 return $self->{_line};
20             }
21              
22             sub _get_column {
23 767     767   1926 my ($self, $field) = @_;
24 767         2141 my $map = $self->field_map->{$field};
25              
26             # if the line is not long enough to handle the start of the field,
27             # it is an optional field that we don't have
28 767 100       4822 if (length($self->{_line}) < $map->[0]) {
29 1         7 return '';
30             }
31              
32 766         2011 my $ret = substr($self->{_line}, $map->[0] - 1, $map->[1]);
33 766         2696 $ret =~ s{\s+\z}{};
34 766         3962 return $ret;
35             }
36              
37             1;
38              
39             __END__