File Coverage

blib/lib/Map/Metro/Graph/Segment.pm
Criterion Covered Total %
statement 17 19 89.4
branch n/a
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 23 27 85.1


line stmt bran cond sub pod time code
1 2     2   22 use 5.10.0;
  2         5  
2 2     2   7 use strict;
  2         3  
  2         37  
3 2     2   6 use warnings;
  2         2  
  2         97  
4              
5             package Map::Metro::Graph::Segment;
6              
7             # ABSTRACT: All lines between two neighboring stations
8             our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9             our $VERSION = '0.2404';
10              
11 2     2   6 use Map::Metro::Elk;
  2         3  
  2         14  
12 2     2   2689 use Types::Standard qw/ArrayRef Str Bool/;
  2         2  
  2         17  
13 2     2   1452 use Map::Metro::Types qw/Station/;
  2         4  
  2         12  
14              
15             has line_ids => (
16             is => 'ro',
17             isa => ArrayRef[Str],
18             traits => ['Array'],
19             required => 1,
20             default => sub { [] },
21             handles => {
22             all_line_ids => 'elements',
23             }
24             );
25             has origin_station => (
26             is => 'ro',
27             isa => Station,
28             required => 1,
29             );
30             has destination_station => (
31             is => 'ro',
32             isa => Station,
33             required => 1,
34             );
35             has is_one_way => (
36             is => 'ro',
37             isa => Bool,
38             default => 0,
39             );
40              
41             sub to_hash {
42 0     0 0   my $self = shift;
43              
44             return {
45 0           line_ids => [ $self->all_line_ids ],
46             origin_station => $self->origin_station->to_hash,
47             destination_station => $self->destination_station->to_hash,
48             is_one_way => $self->is_one_way,
49             };
50             }
51              
52             __PACKAGE__->meta->make_immutable;
53              
54             1;
55              
56             __END__
57              
58             =pod
59              
60             =encoding UTF-8
61              
62             =head1 NAME
63              
64             Map::Metro::Graph::Segment - All lines between two neighboring stations
65              
66             =head1 VERSION
67              
68             Version 0.2404, released 2016-04-30.
69              
70             =head1 DESCRIPTION
71              
72             Segments are used during the graph building phase. Its purpose is to describe the combination of two L<Stations|Map::Metro::Graph::Station>
73             and all L<Lines|Map::Metro::Graph::Line> that go between them.
74              
75             =head1 SOURCE
76              
77             L<https://github.com/Csson/p5-Map-Metro>
78              
79             =head1 HOMEPAGE
80              
81             L<https://metacpan.org/release/Map-Metro>
82              
83             =head1 AUTHOR
84              
85             Erik Carlsson <info@code301.com>
86              
87             =head1 COPYRIGHT AND LICENSE
88              
89             This software is copyright (c) 2016 by Erik Carlsson.
90              
91             This is free software; you can redistribute it and/or modify it under
92             the same terms as the Perl 5 programming language system itself.
93              
94             =cut