Metro/Graph/LineStation.pm

filter: Statementstmt 100% 40 / 40 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 94.3% 50 / 53 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Metro/Hook.pm ↑ Summary Metro/Elk.pm »
1 14 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Map::Metro::Graph::LineStation;
6  
7 # ABSTRACT: A station on a specific line
8 14 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 14 our $VERSION = '0.2404';
10  
11 14 ▶use Map::Metro::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use Types::Standard qw/Int/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 14 ▶use Map::Metro::Types qw/Station Line/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 14 ▶use List::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 14 has line_station_id => (
17 is => 'ro',
18 isa => Int,
19 required => 1,
20 );
21 14 has station => (
22 is => 'ro',
23 isa => Station,
24 required => 1,
25 );
26 14 has line => (
27 is => 'ro',
28 isa => Line,
29 required => 1,
30 );
31  
32 sub possible_on_same_line {
33 1 ▶ my $self = shift;
Subroutine possible_on_same_line: called CC=1 SCAR=0.0
Pod undocumented
34 1 my $other = shift; # LineStation
35  
36 1 my $station_lines = [ map { $_->id } $self->station->all_lines ];
37 1 my $other_station_lines = [ map { $_->id } $other->station->all_lines ];
38  
39 1 my $is_possible = !!List::Compare->new($station_lines, $other_station_lines)->get_intersection;
40  
41 1 return $is_possible;
42 }
43 sub on_same_line {
44 1 ▶ my $self = shift;
Subroutine on_same_line: called CC=1 SCAR=0.0
Pod undocumented
45 1 my $other = shift; # LineStation
46  
47 1 return $self->line->id eq $other->line->id;
48 }
49  
50 sub to_hash {
51 10 ▶ my $self = shift;
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
52  
53 return {
54 10 line_station_id => $self->line_station_id,
55 station => $self->station->to_hash,
56 line => $self->line->to_hash,
57 };
58 }
59  
60 14 __PACKAGE__->meta->make_immutable;
61  
62 14 1;
63  
64 __END__
65  
66 =pod
67  
68 =encoding UTF-8
69  
70 =head1 NAME
71  
72 Map::Metro::Graph::LineStation - A station on a specific line
73  
74 =head1 VERSION
75  
76 Version 0.2404, released 2016-04-30.
77  
78 =head1 DESCRIPTION
79  
80 A line station is the concept of a specific L<Station|Map::Metro::Graph::Station> on a specific L<Line|Map::Metro::Graph::Line>.
81  
82 =head1 METHODS
83  
84 =head2 line_station_id()
85  
86 Returns the internal line station id. Do not depend on this between executions.
87  
88 =head2 station()
89  
90 Returns the L<Station|Map::Metro::Graph::Station> object.
91  
92 =head2 line()
93  
94 Returns the L<Line|Map::Metro::Graph::Line> object.
95  
96 =head1 SOURCE
97  
98 L<https://github.com/Csson/p5-Map-Metro>
99  
100 =head1 HOMEPAGE
101  
102 L<https://metacpan.org/release/Map-Metro>
103  
104 =head1 AUTHOR
105  
106 Erik Carlsson <info@code301.com>
107  
108 =head1 COPYRIGHT AND LICENSE
109  
110 This software is copyright (c) 2016 by Erik Carlsson.
111  
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114  
115 =cut
« Metro/Hook.pm ↑ Summary Metro/Elk.pm »