DBRIS/Formation/Sector.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
TO_JSON
2.0
BEGIN
2.0
CRAP 2.0
1 package Travel::Status::DE::DBRIS::Formation::Sector;
2  
3 use strict;
4 use warnings;
5 use 5.020;
6 use utf8;
7  
8 use parent 'Class::Accessor';
9  
10 our $VERSION = '0.40';
11  
12 Travel::Status::DE::DBRIS::Formation::Sector->mk_ro_accessors(
13 qw(name start_percent end_percent length_percent start_meters end_meters length_meters)
14 );
15  
16 sub new {
17 my ( $obj, %opt ) = @_;
18  
19 my %section = %{ $opt{json} };
20 my %platform = %{ $opt{platform} };
21  
22 my $platform_length = $platform{end} - $platform{start};
23  
24 my $ref = {
25 name => $section{name},
26 start_meters => $section{start},
27 end_meters => $section{end},
28 length_meters => $section{end} - $section{start},
29 start_percent => ( $section{start} - $platform{start} )
30 * 100 / $platform_length,
31 end_percent => ( $section{end} - $platform{start} )
32 * 100 / $platform_length,
33 };
34  
35 $ref->{length_percent} = $ref->{end_percent} - $ref->{start_percent};
36  
37 return bless( $ref, $obj );
38 }
39  
40 sub TO_JSON {
41 my ($self) = @_;
42  
43 my %copy = %{$self};
44  
45 return {%copy};
46 }
47  
48 1;
49