File Coverage

blib/lib/SWIFT/Factory/Tag/Tag15.pm
Criterion Covered Total %
statement 11 32 34.3
branch 0 16 0.0
condition 0 3 0.0
subroutine 4 10 40.0
pod 4 4 100.0
total 19 65 29.2


line stmt bran cond sub pod time code
1             package SWIFT::Factory::Tag::Tag15;
2 1     1   20165 use strict;
  1         3  
  1         48  
3 1     1   6 use warnings;
  1         2  
  1         52  
4              
5             ###########################################################################################################
6             # Provide a SWIFT TAG 15a.
7             #
8             # Use this class to provide all different tags 15A, 15B .. 15Z.
9             #
10             ###########################################################################################################
11              
12             BEGIN{
13 1     1   3 *provide=*string;
14 1         29 *borken=*invalid;
15             }
16              
17 1     1   7 use vars qw($VERSION);
  1         2  
  1         408  
18             $VERSION='0.02';
19              
20             ###########################################################################################################
21             sub new {
22 0     0 1   my$self={};
23 0           bless($self,shift())->_init(@_);
24             }
25              
26             ###########################################################################################################
27             # The class cannot guarantee that the TAG will be valid in the SWIFT network.
28             # It can point out that it's found some invalid data, though.
29             # Return number of problems detected.
30             sub invalid {
31 0     0 1   my$self=shift;
32              
33             # Implement verifications here!
34 0           0;
35             }
36              
37             ###########################################################################################################
38             # If a new Sequence ID is provided, store it for future use.
39             # If requested, return the stored Sequence ID to the caller.
40             sub sequence_id {
41 0     0 1   my($self,$seq_id)=@_;
42 0 0         defined($seq_id)&&$self->_store_seq_id($seq_id);
43 0 0         return(defined(wantarray)?wantarray?($self->{SEQUENCE_ID}):$self->{SEQUENCE_ID}:undef);
    0          
44             }
45              
46             ###########################################################################################################
47             sub string {
48 0     0 1   my$self=shift;
49 0           ':15'.
50             $self->{SEQUENCE_ID}.
51             ':'.
52             chr(13). # CR
53             chr(10); # LF
54             }
55              
56             ###########################################################################################################
57             ###########################################################################################################
58             #
59             # 'Internal' subs. Don't call these since they may, and will, change without notice.
60             #
61             ###########################################################################################################
62             ###########################################################################################################
63              
64             ###########################################################################################################
65             sub _init {
66 0     0     my$self=shift();
67 0           my%args=(
68             DO_CLEANUP=>0,
69             SEQUENCE_ID=>'',
70             @_);
71              
72 0 0         $self->{DO_CLEANUP}=defined($args{DO_CLEANUP})?$args{DO_CLEANUP}?1:0:0;
    0          
73 0           $self->_store_seq_id($args{SEQUENCE_ID});
74 0           $self;
75             }
76              
77             ###########################################################################################################
78             # If Sequence ID is defined, store it together with some simple cleanup applied.
79             sub _store_seq_id {
80 0     0     my($self,$seq_id)=@_;
81              
82 0 0         defined($seq_id)||return;
83              
84 0 0 0       $self->{DO_CLEANUP}&&length($seq_id)>1&&do{
85             # Apply conditional warnings here!
86 0           $seq_id=substr($seq_id,0,1);
87             };
88              
89 0 0         $self->{DO_CLEANUP}&&do{
90             # Apply warnings here too.
91 0           $seq_id=uc($seq_id);
92             };
93              
94 0           $self->{SEQUENCE_ID}=$seq_id;
95             }
96              
97             ###########################################################################################################
98             'Choppers rule';
99             __END__