| 1 | package WWW::EFA::ConnectionsResult; | ||
| 2 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use MooseX::Params::Validate; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use Moose::Util::TypeConstraints; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | with 'WWW::EFA::Roles::Printable'; # provides method 'string' | |
| 7 | |||
| 8 | subtype 'ValidConnectionStatus', | ||
| 9 | as 'Str', | ||
| 10 | 0 | ▶ | where { $_ =~ m/^(OK|AMBIGUOUS|TOO_CLOSE|UNRESOLVABLE_ADDRESS|NO_CONNECTIONS|INVALID_DATE|SERVICE_DOWN)$/ }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 11 | 0 | ▶ | message { "Invalid connection status" }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | =head1 NAME | ||
| 16 | |||
| 17 | WWW::EFA::ConnectionsResult - Store the results from a connection query | ||
| 18 | |||
| 19 | =head1 VERSION | ||
| 20 | |||
| 21 | Version 0.01 | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | 2 | our $VERSION = '0.01'; | |
| 26 | |||
| 27 | |||
| 28 | =head1 SYNOPSIS | ||
| 29 | |||
| 30 | # TODO: RCL 2011-08-23 Complete | ||
| 31 | |||
| 32 | =head1 PARAMS/ACCESSORS | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | 2 | has 'status' => ( | |
| 37 | is => 'rw', | ||
| 38 | isa => 'ValidConnectionStatus', | ||
| 39 | ); | ||
| 40 | |||
| 41 | has 'ambiguous_from' => ( | ||
| 42 | is => 'rw', | ||
| 43 | isa => 'ArrayRef', | ||
| 44 | 0 | ▶ | default => sub{ [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 45 | 2 | ); | |
| 46 | |||
| 47 | has 'ambiguous_via' => ( | ||
| 48 | is => 'rw', | ||
| 49 | isa => 'ArrayRef', | ||
| 50 | 0 | ▶ | default => sub{ [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 51 | 2 | ); | |
| 52 | |||
| 53 | has 'ambiguous_to' => ( | ||
| 54 | is => 'rw', | ||
| 55 | isa => 'ArrayRef', | ||
| 56 | 0 | ▶ | default => sub{ [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 57 | 2 | ); | |
| 58 | |||
| 59 | 2 | has 'request' => ( | |
| 60 | is => 'rw', | ||
| 61 | isa => 'WWW::EFA::Request', | ||
| 62 | required => 1, | ||
| 63 | ); | ||
| 64 | |||
| 65 | 2 | has 'request_id' => ( | |
| 66 | is => 'rw', | ||
| 67 | isa => 'Int', | ||
| 68 | ); | ||
| 69 | |||
| 70 | 2 | has 'origin_location' => ( | |
| 71 | is => 'rw', | ||
| 72 | isa => 'WWW::EFA::Location', | ||
| 73 | ); | ||
| 74 | |||
| 75 | 2 | has 'via_location' => ( | |
| 76 | is => 'rw', | ||
| 77 | isa => 'WWW::EFA::Location', | ||
| 78 | ); | ||
| 79 | |||
| 80 | 2 | has 'destination_location' => ( | |
| 81 | is => 'rw', | ||
| 82 | isa => 'WWW::EFA::Location', | ||
| 83 | ); | ||
| 84 | |||
| 85 | has 'routes' => ( | ||
| 86 | is => 'rw', | ||
| 87 | isa => 'ArrayRef', | ||
| 88 | 0 | ▶ | default => sub{ [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 89 | 2 | ); | |
| 90 | |||
| 91 | =head1 METHODS | ||
| 92 | |||
| 93 | =head2 add_route( $route ) | ||
| 94 | |||
| 95 | Add a L<WWW::EFA::Route> to the result | ||
| 96 | |||
| 97 | =cut | ||
| 98 | 0 | ▶ | sub add_route { |
|
Subroutine
add_route: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 99 | 0 | my $self = shift; | |
| 100 | 0 | my ( $route ) = pos_validated_list( | |
| 101 | \@_, | ||
| 102 | { isa => 'WWW::EFA::Route' }, | ||
| 103 | ); | ||
| 104 | 0 | my @routes = @{ $self->routes }; | |
| 105 | 0 | push( @routes, $route ); | |
| 106 | 0 | @routes = sort{ $a->departure_time <=> $b->departure_time } @routes; | |
| 107 | 0 | $self->routes( \@routes ); | |
| 108 | } | ||
| 109 | |||
| 110 | |||
| 111 | 2 | 1; | |
| 112 | |||