| 1 | |||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | package GPS::Magellan::Coord; | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 10 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||
| 10 | 10 | my $proto = shift; | |||||||||||||||||||
| 11 | 10 | my $raw_data = shift; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 10 | ▶ | die "GPS::Magellan::Coord::new() didn't get raw data\n" unless $raw_data; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 10 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 10 | my $self = bless { }, $class; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 10 | $self->fields( [ qw/longitude lnsign latitude ltsign altitude unknown name description icon/ ] ); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 10 | $self->_parse($raw_data); | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 10 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 10 | ▶ | sub _parse { | ||||||||||||||||||
|
Subroutine
_parse: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 27 | 10 | my $self = shift; | |||||||||||||||||||
| 28 | 10 | ▶ | my $raw_data = shift or die "GPS::Magellan::Coord->new() didn't get raw data\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 10 | my @fields = qw/longitude lnsign latitude ltsign altitude unknown name description icon/; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 10 | foreach my $val (split /,/, $raw_data){ | |||||||||||||||||||
| 33 | 90 | my $field = shift @fields; | |||||||||||||||||||
| 34 | 90 | $self->_set($field, $val); | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | sub _dump { | ||||||||||||||||||
|
Subroutine
_dump: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | my @fields = qw/longitude lnsign latitude ltsign altitude unknown name description icon/; | |||||||||||||||||||
| 43 | 0 | foreach my $field (@fields){ | |||||||||||||||||||
| 44 | 0 | printf "%20s -> %20s\n", $field, $self->_get($field); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | # Accessors | ||||||||||||||||||||
| 49 | 320 | ▶ | sub _get { | ||||||||||||||||||
|
Subroutine
_get: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 50 | 320 | my $self = shift; | |||||||||||||||||||
| 51 | 320 | my $attr = shift; | |||||||||||||||||||
| 52 | 320 | return $self->{$attr}; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 100 | ▶ | sub _set { | ||||||||||||||||||
|
Subroutine
_set: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 56 | 100 | my $self = shift; | |||||||||||||||||||
| 57 | 100 | my $attr = shift; | |||||||||||||||||||
| 58 | 100 | ▶ | my $value = shift || ''; | ||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 100 | ▶ | return unless $attr; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 100 | $self->{$attr} = $value; | |||||||||||||||||||
| 63 | 100 | return $self->_get($attr); | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 110 | ▶ | sub _debug_autoload { | ||||||||||||||||||
|
Subroutine
_debug_autoload: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 67 | 110 | my $self = shift; | |||||||||||||||||||
| 68 | 110 | ▶ | $self->_set('_debug_autoload', shift) if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | 110 | $self->_get('_debug_autoload'); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 110 | ▶ | sub AUTOLOAD { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=14.0
| |||||||||||||||||||||
| 74 | 110 | my $self = shift; | |||||||||||||||||||
| 75 | 110 | my $attr = $AUTOLOAD; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 110 | $attr =~ s/.*:://; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 110 | ▶ | return if $attr =~ /^_/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 110 | ▶ | warn "AUTOLOAD: $attr\n" if $self->_debug_autoload; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 110 | ▶ | if(@_){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | 10 | $self->_set($attr, shift); | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | 110 | return $self->_get($attr); | |||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 1 | 1; | |||||||||||||||||||
| 95 | |||||||||||||||||||||