File Coverage

blib/lib/Device/MindWave/Packet/ThinkGear/DataValue/Attention.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 5 5 100.0
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Device::MindWave::Packet::ThinkGear::DataValue::Attention;
2              
3 5     5   21362 use strict;
  5         9  
  5         163  
4 5     5   24 use warnings;
  5         6  
  5         135  
5              
6 5     5   493 use Device::MindWave::Utils qw(checksum);
  5         9  
  5         256  
7              
8 5     5   24 use base qw(Device::MindWave::Packet::ThinkGear::DataValue);
  5         14  
  5         1574  
9              
10             sub new
11             {
12 3     3 1 38 my ($class, $bytes, $index) = @_;
13              
14 3         11 my $self = { value => $bytes->[$index + 1] };
15 3         10 bless $self, $class;
16 3         12 return $self;
17             }
18              
19             sub as_bytes
20             {
21 2     2 1 847 my ($self) = @_;
22              
23 2         22 return [ 0x04, $self->{'value'} ];
24             }
25              
26             sub length
27             {
28 3     3 1 10 return 2;
29             }
30              
31             sub as_string
32             {
33 2     2 1 618 my ($self) = @_;
34              
35 2         13 return "Attention (".$self->{'value'}."/100)";
36             }
37              
38             sub as_hashref
39             {
40 2     2 1 7 my ($self) = @_;
41              
42 2         17 return { Attention => $self->{'value'} };
43             }
44              
45             1;
46              
47             __END__