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-2006 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             # $Id$
13              
14             package Sms::Token::MR;
15 1     1   8 use integer;
  1         2  
  1         9  
16 1     1   32 use strict;
  1         2  
  1         37  
17 1     1   5 use Device::Gsm::Sms::Token;
  1         2  
  1         227  
18              
19             @Sms::Token::MR::ISA = ('Sms::Token');
20              
21             # takes (scalar message (string) reference)
22             # returns success/failure of decoding
23             # if all ok, removes token from message
24             sub decode {
25 2     2   5 my ($self, $rMessage) = @_;
26 2         4 my $ok = 0;
27              
28 2         14 $self->data(hex substr($$rMessage, 0, 2));
29 2         10 $self->state(Sms::Token::DECODED);
30              
31             # Remove MR from message
32 2         5 $$rMessage = substr($$rMessage, 2);
33              
34 2         9 return 1;
35             }
36              
37             #
38             # [token]->encode( [$data] )
39             #
40             # takes internal token data and encodes it, returning the result
41             # or undef value in case of errors
42             #
43             sub encode {
44 0     0     my $self = shift;
45              
46             # Take supplied data (optional) or object internal data
47 0           my $data = shift;
48 0 0 0       if (!defined $data || $data eq '') {
49 0           $data = $self->data();
50 0   0       $data ||= '00';
51             }
52              
53 0           return $data;
54             }
55              
56             1;