| 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.2405'; | |
| 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 | 1 | ▶ | sub possible_on_same_line { |
|
Subroutine
possible_on_same_line: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 33 | 1 | my $self = shift; | |
| 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 | 1 | ▶ | sub on_same_line { |
|
Subroutine
on_same_line: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 44 | 1 | my $self = shift; | |
| 45 | 1 | my $other = shift; # LineStation | |
| 46 | |||
| 47 | 1 | return $self->line->id eq $other->line->id; | |
| 48 | } | ||
| 49 | |||
| 50 | 10 | ▶ | sub to_hash { |
|
Subroutine
to_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 51 | 10 | my $self = shift; | |
| 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__ | ||