File Coverage

blib/lib/Device/Gsm/Sms/Token/MR.pm
Criterion Covered Total %
statement 15 21 71.4
branch 0 2 0.0
condition 0 5 0.0
subroutine 4 5 80.0
pod n/a
total 19 33 57.5


line stmt bran cond sub pod time code
1             # Sms::Token::MR - SMS MR (data coding scheme) token
2             # Copyright (C) 2002-2015 Cosimo Streppone, cosimo@cpan.org
3             #
4             # This program is free software; you can redistribute it and/or modify
5             # it only under the terms of Perl itself.
6             #
7             # This program is distributed in the hope that it will be useful,
8             # but WITHOUT ANY WARRANTY; without even the implied warranty of
9             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10             # Perl licensing terms for details.
11              
12             package Sms::Token::MR;
13 1     1   3 use integer;
  1         1  
  1         5  
14 1     1   21 use strict;
  1         1  
  1         13  
15 1     1   3 use Device::Gsm::Sms::Token;
  1         1  
  1         118  
16              
17             @Sms::Token::MR::ISA = ('Sms::Token');
18              
19             # takes (scalar message (string) reference)
20             # returns success/failure of decoding
21             # if all ok, removes token from message
22             sub decode {
23 2     2   3 my ($self, $rMessage) = @_;
24 2         2 my $ok = 0;
25              
26 2         6 $self->data(hex substr($$rMessage, 0, 2));
27 2         7 $self->state(Sms::Token::DECODED);
28              
29             # Remove MR from message
30 2         2 $$rMessage = substr($$rMessage, 2);
31              
32 2         5 return 1;
33             }
34              
35             #
36             # [token]->encode( [$data] )
37             #
38             # takes internal token data and encodes it, returning the result
39             # or undef value in case of errors
40             #
41             sub encode {
42 0     0     my $self = shift;
43              
44             # Take supplied data (optional) or object internal data
45 0           my $data = shift;
46 0 0 0       if (!defined $data || $data eq '') {
47 0           $data = $self->data();
48 0   0       $data ||= '00';
49             }
50              
51 0           return $data;
52             }
53              
54             1;