From 0af0e74c701d229484c491af52dc20ae4b29e552 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 6 Mar 2012 01:07:07 -0600 Subject: documentation --- lib/Term/Filter/Callback.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/Term/Filter') diff --git a/lib/Term/Filter/Callback.pm b/lib/Term/Filter/Callback.pm index 4a32352..d5920a0 100644 --- a/lib/Term/Filter/Callback.pm +++ b/lib/Term/Filter/Callback.pm @@ -6,12 +6,43 @@ with 'Term::Filter'; =head1 SYNOPSIS + use Term::Filter::Callback; + + my $term = Term::Filter::Callback->new( + callbacks => { + munge_input => sub { + my $self = shift; + my ($got) = @_; + $got =~ s/\ce/E- Elbereth\n/g; + $got; + }, + munge_output => sub { + my $self = shift; + my ($got) = @_; + $got =~ s/(Elbereth)/\e[35m$1\e[m/g; + $got; + }, + }, + ); + + $term->run('nethack'); + =head1 DESCRIPTION +This module provides a callback-based API to L. The desired +callbacks can just be passed into the constructor of this class, rather than +requiring a new class to be manually defined. This class consumes the +L role, so the rest of the documentation in that module applies +here. + =cut =attr callbacks +A hashref of callbacks for L. The keys are +L and the values are coderefs to call +for those callbacks. + =cut has callbacks => ( -- cgit v1.2.3-54-g00ecf