NAME

OpenGbg::Service::Bridge::BridgeOpenings - A list of bridge openings/closings

VERSION

Version 0.1404, released 2018-05-19.

SYNOPSIS

my $bridge = OpenGbg->new->bridge;
my $get_os = $bridge->get_opened_status;

my $opening = $get_opened_status->bridge_openings->get_by_index(5);

printf 'It was %s at %s on %s', $opening->was_open ? 'open' : 'closed', $opening->timestamp->hms, $opening->timestamp->ymd;

METHODS

all

Returns an array of the OpenGbg::Service::Bridge::BridgeOpening objects in the response.

count

Returns the number of BridgeOpening objects in the response.

filter(sub { ... })

Allows filtering of the bridge openings. Takes a sub routine reference, into which all BridgeOpening objects are passed one-by-one into $_. Works like grep. For example, to get the number of times the bridge was open:

use List::AllUtils 'sum'; my $opening_count = scalar $get_opened_status->bridge_openings->filter(sub { $_->was_open });

find(sub { ... })

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

get_by_index($index)

Returns the n:th OpenGbg::Service::Bridge::BridgeOpening object in the response.

map(sub { ... })

Like filter it takes a sub routine reference and passes each BridgeOpening as $_.

sort(sub { ... })

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

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.