NAME

OpenGbg::Service::AirQuality::Measurements - A list of air quality measurements

VERSION

Version 0.1404, released 2018-05-19.

SYNOPSIS

    my $service = OpenGbg->new->air_quality;
    my $response = $service->get_measurements(start => '2014-10-15', end => '2014-10-25');

    print $response->measurements->get_by_index(3)->to_text;

METHODS

all

Returns an array of the OpenGbg::Service::AirQuality::Measurement objects in the response.

count

Returns the number of Measurement objects in the response.

filter(sub { ... })

Allows filtering of the measurements. Takes a sub routine reference, into which all Measurement objects are passed one-by-one into $_. Works like grep.

find(sub { ... })

Just like filter, except it returns the first measurement that matches.

get_by_index($index)

Returns the n:th Measurement object in the response.

map(sub { ... })

Like filter it takes a sub routine reference and passes each Measurement as $_. Eg, to get the total solar insolation:

    use List::AllUtils 'sum';
    my $total_solar_insolation_per_m2 = sum $response->measurements->map( sub { $_->solar_insolation });

sort(sub { ... })

Like filter it takes a sub routine reference. It works just like sort except the two Measurement objects to compare are passed as $_[0] and $_[1]

    my @hottest_hours_first = $response->measurements->sort( sub { $_[1]->temperature <=> $_[0]->temperature });

SOURCE

https://github.com/Csson/p5-OpenGbg

HOMEPAGE

https://metacpan.org/release/OpenGbg

AUTHOR

Erik Carlsson <info@code301.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Erik Carlsson.

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