| 1 | package WWW::EFA::DepartureFactory; | ||||||||||||||||||||
| 2 | 2 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use Class::Date qw/date/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use WWW::EFA::Departure; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use WWW::EFA::DateFactory; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | A Factory for creating L<WWW::EFA::Departure> objects. | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | my $factory = WWW::EFA::DepartureFactory->new(); | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | Version 0.01 | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | our $VERSION = '0.01'; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | =head1 ATTRIBUTES | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # TODO: RCL 2012-01-22 Document attributes | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | has 'map_departure' => ( is => 'ro', isa => 'HashRef', required => 1, | ||||||||||||||||||||
| 29 | 0 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 30 | { | ||||||||||||||||||||
| 31 | 0 | stopID => 'stop_id', | |||||||||||||||||||
| 32 | area => 'area', | ||||||||||||||||||||
| 33 | platform => 'platform', | ||||||||||||||||||||
| 34 | platform_name => 'platform_name', | ||||||||||||||||||||
| 35 | countdown => 'countdown', | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | }, | ||||||||||||||||||||
| 38 | 2 | ); | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | has 'date_factory' => ( | ||||||||||||||||||||
| 41 | is => 'ro', | ||||||||||||||||||||
| 42 | isa => 'WWW::EFA::DateFactory', | ||||||||||||||||||||
| 43 | required => 1, | ||||||||||||||||||||
| 44 | lazy => 1, | ||||||||||||||||||||
| 45 | 0 | ▶ | default => sub{ WWW::EFA::DateFactory->new() }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 46 | 2 | ); | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 METHODS | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | =head2 departure_from_itdDeparture | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | Returns a L<WWW::EFA::Departure> object | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | my $departure = $factory->departure_from_itdDeparture( $itd_odv->findnodes( '/itdDeparture' ) ); | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | Expects an XML::LibXML::Element of XML like this: | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | <itdDeparture stopID="8" x="11536492.00000" y="48142609.00000" mapName="WGS84" area="1" | ||||||||||||||||||||
| 61 | platform="S-RiW" platformName="" stopName="Donnersbergerbrücke" | ||||||||||||||||||||
| 62 | nameWO="Donnersbergerbrücke" countdown="1"> | ||||||||||||||||||||
| 63 | <itdDateTime> | ||||||||||||||||||||
| 64 | <itdDate year="2011" month="11" day="4" weekday="6"/> | ||||||||||||||||||||
| 65 | <itdTime hour="15" minute="9" ap=""/> | ||||||||||||||||||||
| 66 | </itdDateTime> | ||||||||||||||||||||
| 67 | <itdServingLine key="1424" code="2" number="S8" symbol="S8" | ||||||||||||||||||||
| 68 | motType="1" realtime="0" direction="Herrsching" destID="5410" | ||||||||||||||||||||
| 69 | stateless="mvv:01008:B:R:s11"> | ||||||||||||||||||||
| 70 | <itdNoTrain name="S-Bahn"/> | ||||||||||||||||||||
| 71 | <motDivaParams line="01008" project="s11" direction="R" supplement="B" network="mvv"/> | ||||||||||||||||||||
| 72 | </itdServingLine> | ||||||||||||||||||||
| 73 | </itdDeparture> | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||
| 77 | 0 | ▶ | sub departure_from_itdDeparture { | ||||||||||||||||||
|
Subroutine
departure_from_itdDeparture: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||
| 79 | 0 | my $element = shift; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | my %dep_params = | ||||||||||||||||||||
| 82 | 0 | map { $self->map_departure->{ $_ } => $element->getAttribute( $_ ) } | |||||||||||||||||||
| 83 | 0 | ▶ | grep { $element->hasAttribute( $_ ) and $element->getAttribute( $_ ) } | ||||||||||||||||||
|
Condition0%0/3
$element->hasAttribute($_) && $element->getAttribute($_)
MC/DC0%0/2
$element->hasAttribute($_) && $element->getAttribute($_)
$element->hasAttribute($_)
$element->getAttribute($_)
Truth table0%0/3
A && B
A= $element->hasAttribute($_)B= $element->getAttribute($_)
| |||||||||||||||||||||
| 84 | 0 | keys %{ $self->map_departure }; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | my( $date_elem ) = $element->findnodes( 'itdDateTime' ); | |||||||||||||||||||
| 87 | 0 | ▶ | if( $date_elem ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 0 | $dep_params{time} = $self->date_factory->date_from_itdDateTime( $date_elem ); | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | my( $line_elem ) = $element->findnodes( 'itdServingLine' ); | |||||||||||||||||||
| 92 | 0 | $dep_params{line_id} = $line_elem->getAttribute( 'stateless' ); | |||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | my $departure = WWW::EFA::Departure->new( %dep_params ); | |||||||||||||||||||
| 95 | 0 | return $departure; | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 2 | 1; | |||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head1 COPYRIGHT | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | Copyright 2011, Robin Clarke, Munich, Germany | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =head1 AUTHOR | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | Robin Clarke <perl@robinclarke.net> | ||||||||||||||||||||
| 108 | |||||||||||||||||||||