File Coverage

blib/lib/Device/MindWave/Packet/Dongle/HeadsetDisconnected.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 5 5 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Device::MindWave::Packet::Dongle::HeadsetDisconnected;
2              
3 5     5   20943 use strict;
  5         10  
  5         150  
4 5     5   25 use warnings;
  5         9  
  5         169  
5              
6 5     5   474 use Device::MindWave::Utils qw(checksum);
  5         9  
  5         263  
7              
8 5     5   33 use base qw(Device::MindWave::Packet::Dongle);
  5         16  
  5         1617  
9              
10             sub new
11             {
12 5     5 1 859 my ($class, $bytes, $index) = @_;
13              
14 5         26 my $self = { headset_upper => $bytes->[$index + 2],
15             headset_lower => $bytes->[$index + 3] };
16 5         21 bless $self, $class;
17 5         32 return $self;
18             }
19              
20             sub code
21             {
22 1     1 1 789 return 0xD2;
23             }
24              
25             sub as_bytes
26             {
27 3     3 1 15 my ($self) = @_;
28              
29 3         36 return [ 0xD2, 0x02,
30             $self->{'headset_upper'},
31             $self->{'headset_lower'} ];
32             }
33              
34             sub length
35             {
36 1     1 1 3 return 4;
37             }
38              
39             sub as_string
40             {
41 1     1 1 479 my ($self) = @_;
42              
43 1         27 return sprintf "Headset (%X%X) disconnected",
44             $self->{'headset_upper'},
45             $self->{'headset_lower'};
46             }
47              
48             1;
49              
50             __END__