NAME

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

SYNOPSIS

my $aq = OpenGbg->new->air_quality;
my $response = $aq->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 OpenGbg::Service::AirQuality::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 });

AUTHOR

Erik Carlsson <info@code301.com>

COPYRIGHT

Copyright 2014 - Erik Carlsson

LICENSE

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