File Coverage

blib/lib/Protocol/FIX/TagsAccessor.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 3 3 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Protocol::FIX::TagsAccessor;
2              
3 11     11   76 use strict;
  11         26  
  11         343  
4 11     11   61 use warnings;
  11         23  
  11         2475  
5              
6             our $VERSION = '0.06'; ## VERSION
7              
8             =head1 NAME
9              
10             Protocol::FIX::TagsAccessor - access to tags of deserialized FIX messages
11              
12             =cut
13              
14             =head1 METHODS
15              
16             =head3 new
17              
18             new($class, $tag_pairs)
19              
20             Creates new TagsAccessor (performed by Parser). Not for direct usage
21             by end-users.
22              
23             =cut
24              
25             sub new {
26 53     53 1 159 my ($class, $tag_pairs) = @_;
27 53         82 my %by_name;
28 53         85 my $count = 0;
29 53         148 for (my $idx = 0; $idx < @$tag_pairs; $idx += 2) {
30 134         208 my $composite = $tag_pairs->[$idx];
31             # value is either value (i.e. string) or another TagAccessor
32 134         215 my $value = $tag_pairs->[$idx + 1];
33 134         346 $by_name{$composite->{name}} = $value;
34 134         280 ++$count;
35             }
36 53         112 $by_name{_count} = $count;
37 53         211 return bless \%by_name, $class;
38             }
39              
40             =head3 value
41              
42             value($self, $name)
43              
44             Returns value. Please, refer to L
45              
46             =cut
47              
48             sub value {
49 76     76 1 5919 my ($self, $name) = @_;
50 76         352 return $self->{$name};
51             }
52              
53             =head3 count
54              
55             count($self)
56              
57             Returns the count for the repetitive tag pairs
58              
59             =cut
60              
61             sub count {
62 18     18 1 27 my $self = shift;
63 18         68 return $self->{_count};
64             }
65              
66             1;