| 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::Connection; | ||||||||||||||
| 6 | |||||||||||||||
| 7 | # ABSTRACT: Connects two stations on a 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/Maybe Int/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 14 | ▶ | use Map::Metro::Types qw/LineStation Connection/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 14 | ▶ | use PerlX::Maybe qw/maybe/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | |||||||||||||||
| 16 | 14 | has origin_line_station => ( | |||||||||||||
| 17 | is => 'ro', | ||||||||||||||
| 18 | isa => LineStation, | ||||||||||||||
| 19 | required => 1, | ||||||||||||||
| 20 | ); | ||||||||||||||
| 21 | 14 | has destination_line_station => ( | |||||||||||||
| 22 | is => 'ro', | ||||||||||||||
| 23 | isa => LineStation, | ||||||||||||||
| 24 | required => 1, | ||||||||||||||
| 25 | ); | ||||||||||||||
| 26 | 14 | has previous_connection => ( | |||||||||||||
| 27 | is => 'rw', | ||||||||||||||
| 28 | isa => Maybe[ Connection ], | ||||||||||||||
| 29 | predicate => 1, | ||||||||||||||
| 30 | ); | ||||||||||||||
| 31 | 14 | has next_connection => ( | |||||||||||||
| 32 | is => 'rw', | ||||||||||||||
| 33 | isa => Maybe[ Connection ], | ||||||||||||||
| 34 | predicate => 1, | ||||||||||||||
| 35 | ); | ||||||||||||||
| 36 | 14 | has weight => ( | |||||||||||||
| 37 | is => 'ro', | ||||||||||||||
| 38 | isa => Int, | ||||||||||||||
| 39 | required => 1, | ||||||||||||||
| 40 | default => 1, | ||||||||||||||
| 41 | ); | ||||||||||||||
| 42 | |||||||||||||||
| 43 | sub to_hash { | ||||||||||||||
| 44 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
to_hash: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 45 | |||||||||||||||
| 46 | return { | ||||||||||||||
| 47 | 0 | ▶ | origin_line_station => $self->origin_line_station->to_hash, | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 48 | destination_line_station => $self->destination_line_station->to_hash, | ||||||||||||||
| 49 | maybe previous_connection => $self->has_previous_connection ? $self->previous_connection->to_hash : undef, | ||||||||||||||
| 50 | maybe next_connection => $self->has_next_connection ? $self->next_connection->to_hash : undef, | ||||||||||||||
| 51 | weight => $self->weight, | ||||||||||||||
| 52 | }; | ||||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 14 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 56 | |||||||||||||||
| 57 | 14 | 1; | |||||||||||||
| 58 | |||||||||||||||
| 59 | __END__ | ||||||||||||||
| 60 | |||||||||||||||
| 61 | =pod | ||||||||||||||
| 62 | |||||||||||||||
| 63 | =encoding UTF-8 | ||||||||||||||
| 64 | |||||||||||||||
| 65 | =head1 NAME | ||||||||||||||
| 66 | |||||||||||||||
| 67 | Map::Metro::Graph::Connection - Connects two stations on a line | ||||||||||||||
| 68 | |||||||||||||||
| 69 | =head1 VERSION | ||||||||||||||
| 70 | |||||||||||||||
| 71 | Version 0.2404, released 2016-04-30. | ||||||||||||||
| 72 | |||||||||||||||
| 73 | =head1 DESCRIPTION | ||||||||||||||
| 74 | |||||||||||||||
| 75 | Connections represent the combination of two specific L<LineStations|Map::Metro::Graph::LineStation>, and the 'cost' of | ||||||||||||||
| 76 | travelling between them. | ||||||||||||||
| 77 | |||||||||||||||
| 78 | In L<Graph> terms, a connection is a weighted edge. | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =head1 SOURCE | ||||||||||||||
| 81 | |||||||||||||||
| 82 | L<https://github.com/Csson/p5-Map-Metro> | ||||||||||||||
| 83 | |||||||||||||||
| 84 | =head1 HOMEPAGE | ||||||||||||||
| 85 | |||||||||||||||
| 86 | L<https://metacpan.org/release/Map-Metro> | ||||||||||||||
| 87 | |||||||||||||||
| 88 | =head1 AUTHOR | ||||||||||||||
| 89 | |||||||||||||||
| 90 | Erik Carlsson <info@code301.com> | ||||||||||||||
| 91 | |||||||||||||||
| 92 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||
| 93 | |||||||||||||||
| 94 | This software is copyright (c) 2016 by Erik Carlsson. | ||||||||||||||
| 95 | |||||||||||||||
| 96 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||
| 97 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||
| 98 | |||||||||||||||
| 99 | =cut | ||||||||||||||