BusyBird::Filter - common utilities about status filters
use BusyBird; use BusyBird::Filter qw(:all); my $drop_low_level = filter_map sub { my $status = shift; return $status->{busybird}{level} > 5 ? ($status) : (); }; my $set_level = filter_each sub { my $status = shift; $status->{busybird}{level} = 10; }; timeline("home")->add_filter($drop_low_level); timeline("home")->add_filter($set_level);
This module provides some functions to create status filters.
A status filter is a subroutine reference to process an array-ref of statuses. See BusyBird::Timeline's add_filter() method for details about status filters.
add_filter()
Some modules provide pre-defined filters for you.
Filters and transformations useful when you import statuses from Twitter.
You can import any of the functions below. None of them is exported by default. Import ":all" to import all functions at once.
":all"
Creates a synchronous status filter that modifies each of the statuses destructively.
$func is a subroutine reference that takes a single status. For each status, $func is called like
$func
$func->($status)
$func is supposed to modify the given $status destructively. The result of the $filter is the list of modified statuses.
$status
$filter
Return value from $func is ignored.
Creates a synchronous status filter that maps each of the statuses. This is similar to Perl's built-in map() function.
map()
@mapped_statuses = $func->($status)
$func is supposed to return a list of statuses. The result of the $filter is all statuses collected from the $func.
Note that the $status given to $func is a deep clone of the original status. Even if you modify $status in $func, the original status is intact.
Creates a synchronous status filter that picks up statuses by $func This is simalar to Perl's built-in grep() function.
grep()
$func is a subroutine reference that is called for each input status. $func is called in scalar context as in:
$result = $func->($status)
If $result is true, that $status is passed to the next. If $result is false, the $status is filtered out.
$result
You should not modify $status within $func.
BusyBird::Manual::Status
BusyBird::Timeline
Toshio Ito <toshioito [at] cpan.org>
<toshioito [at] cpan.org>
To install BusyBird, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BusyBird
CPAN shell
perl -MCPAN -e shell install BusyBird
For more information on module installation, please visit the detailed CPAN module installation guide.