Transport::AU::PTV::Collection
version 0.01
Transport::AU::PTV::Collecton - parent class for Transport::AU::PTV collection objects.
my @names = $collection->map(sub { $_->name });
Iterates over each object in the collection and runs subroutine. Each object is passed in to the sub as $_.
$_
Returns an array of the return value of each subroutine. The number of array elements will always equal the number of objects in the collection.
my @matches = $collection->grep(sub { $_->name =~ s{A...b}xms };
Iterates over each of the objects and returns a Transport::AU::PTV::Collection object of all the objects for which the subroutine passed to grep returned 'true'.
grep
my $match = $collection->first(sub { $_->name eq 'A_Name' });
Like grep, but returns the first object for which the subroutine returns true.
my $value = $collection->find({ name => 'value' });
Syntactic sugar for $collection-first(sub { $_->name eq 'value' });>. The key of the hashref is the method to run on the object. The value of the hashref is the expected return from that method. Equality is determined using 'eq', thus the return values are stringified before testing.
$collection-
Returns the number of objects in the collection.
for my $object ($collection->as_array) { ... }
Returns the collection as an array of objects. No copying occurs, so the objects are references to the same objects within the collection.
Greg Foletta <greg@foletta.org>
This software is copyright (c) 2018 by Greg Foletta.
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 Transport::AU::PTV, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Transport::AU::PTV
CPAN shell
perl -MCPAN -e shell install Transport::AU::PTV
For more information on module installation, please visit the detailed CPAN module installation guide.