OpenGbg::Service::StyrOchStall::GetBikeStations - Get data on all bike stations
Version 0.1404, released 2018-05-19.
my $service = OpenGbg->new->styr_och_stall; my $stations = $service->get_bike_stations; printf 'Time: %s', $stations->timestamp; print $stations->get_by_index(5)->to_text;
Returns the timestamp given in the response as a DateTime object.
Returns an array of the OpenGbg::Service::StyrOchStall::Station objects in the response.
Returns the number of Station objects in the response.
Allows filtering of the stations. Takes a sub routine reference, into which all Station objects are passed one-by-one into $_. Works like grep.
$_
grep
Just like filter, except it returns the first station that matches.
filter
Returns the n:th OpenGbg::Service::StyrOchStall::Station object in the response.
Returns the station with id $id.
$id
Like filter it takes a sub routine reference and passes each Station as $_. Eg, to get a total count of free bikes:
use List::AllUtils 'sum'; my $free_bikes_count = sum $response->stations->map( sub { $_->free_bikes });
Like filter it takes a sub routine reference. It works just like sort except the two Station objects to compare are passed as $_[0] and $_[1]
sort
$_[0]
$_[1]
my @most_bikes_first = $response->stations->sort( sub { $_[1]->free_bikes <=> $_[0]->free_bikes });
https://github.com/Csson/p5-OpenGbg
https://metacpan.org/release/OpenGbg
Erik Carlsson <info@code301.com>
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.
To install OpenGbg, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenGbg
CPAN shell
perl -MCPAN -e shell install OpenGbg
For more information on module installation, please visit the detailed CPAN module installation guide.