The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::AzimuthAero::Flight - Flight representation

VERSION

version 0.3

SYNOPSIS

    my $flight = WWW::AzimuthAero::Flight->new(
        from_city => 'ROV',
        to_city   => 'KLF',
        flight_date => '16.06.2019'
    );

DESCRIPTION

Object representation of data on pages like https://booking.azimuth.aero/!/ROV/LED/21.06.2019/1-0-0/

METHODS

new

    my $az = WWW::AzimuthAero::Flight->new(date => '16.06.2019', from => 'ROV', to => 'KLF');

PROPERTIES

from_city

Departure city IATA code

Example:

    LED

to_city

Arrival city IATA code

Example:

    ROV

flight_num

Return string with flight number

Example:

    A4 203

flight_date

String in %d.%m.%Y format

Example:

    24.06.2019

departure_time

Example:

    07:20

arrival_time

Example:

    10:00

trip_duration

Example:

    5ч 35м

fares

Contain hash with different tariffs

{ 'lowest' => '10680', 'optimalnyy' => '10680', 'svobodnyy' => '11980' }

Possible keys are

    qw/legkiy vygodnyy optimalnyy svobodnyy/

lowest key always contains lowest price

has_stops

Return true if flight consist of two flights

Like at https://booking.azimuth.aero/!/ROV/PKV/26.06.2019/1-0-0/

stop_at_city

Return IATA code of transit city

as_hashref

Return particular properties as hash

    $f->as_hash;
    $f->as_hash( skip => [ qw/fares/ ] )
    $flight->as_hash( only => [ qw/from_city to_city flight_date/ ] )

If class has such method but it's not set - will return undef in value

Convenient when inserting data to database, especially with DBIx::Class::ResultSet

    $schema->resultset('Flight')->create( $f->as_hash( skip => [ qw/fares/ ] ) )

Params:

only - Which fields to return only

skip - Which fields skip from result = 'all except'

skip_undef - To skip or not undef values (useful to supress warning in concatenation)

as_string

Return flight info as string

Support same parameters as WWW::AzimuthAero::Flight (in facts it's wrapper on it)

    $f->as_string;
    $f->as_string( skip => [ qw/fares/ ] )
    $flight->as_string( only => [ qw/from_city to_city flight_date/ ] )

Additional parameters

order

    $f->as_string( order => [ qw/price flight_date/ ] )

By default (in order not specified) prints parameters in alphabetic order

Method could be useful for logging

separator

    $f->as_string( separator => "\t" )

Useful when you create a table

AUTHOR

Pavel Serikov <pavelsr@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Pavel Serikov.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.