File Coverage

blib/lib/Device/RFXCOM/Response.pm
Criterion Covered Total %
statement 31 31 100.0
branch 10 10 100.0
condition n/a
subroutine 16 16 100.0
pod 11 11 100.0
total 68 68 100.0


line stmt bran cond sub pod time code
1 4     4   20 use strict;
  4         8  
  4         145  
2 4     4   19 use warnings;
  4         7  
  4         197  
3             package Device::RFXCOM::Response;
4             $Device::RFXCOM::Response::VERSION = '1.142010';
5             # ABSTRACT: Device::RFXCOM::Response class for data from RFXCOM receiver
6              
7              
8 4     4   88 use 5.006;
  4         12  
  4         146  
9 4     4   19 use constant DEBUG => $ENV{DEVICE_RFXCOM_RESPONSE_DEBUG};
  4         6  
  4         339  
10 4     4   21 use Carp qw/croak/;
  4         7  
  4         1480  
11              
12              
13             sub new {
14 97     97 1 460 my ($pkg, %p) = @_;
15 97         1147 bless { %p }, $pkg;
16             }
17              
18              
19 104     104 1 559 sub type { shift->{type} }
20              
21              
22 104     104 1 583 sub header_byte { shift->{header_byte} }
23              
24              
25 104     104 1 598 sub master { shift->{master} }
26              
27              
28 101     101 1 275 sub hex_data { unpack 'H*', shift->data }
29              
30              
31 108     108 1 564 sub data { shift->{data} }
32              
33              
34 7     7 1 27 sub length { length shift->data }
35              
36              
37 3     3 1 22 sub bytes { shift->{bytes} }
38              
39              
40 103 100   103 1 635 sub messages { shift->{messages} || [] }
41              
42              
43 98     98 1 1219 sub duplicate { shift->{duplicate} }
44              
45              
46             sub summary {
47 97     97 1 120551 my $self = shift;
48 97         164 my $str = join "\n ", map { $_->summary } @{$self->messages};
  112         497  
  97         215  
49 97 100       301 sprintf('%s %s %02x.%s%s%s',
    100          
    100          
    100          
50             $self->master ? 'master' : 'slave',
51             $self->type,
52             $self->header_byte,
53             $self->hex_data,
54             $self->duplicate ? '(dup)' : '',
55             $str =~ /\n/ ? ":\n ".$str : $str ne '' ? ': '.$str : '');
56             }
57              
58             1;
59              
60             __END__