[libcatmandu-perl] 34/46: Adding POD for Buffer
Jonas Smedegaard
dr at jones.dk
Tue Oct 14 13:52:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9205
in repository libcatmandu-perl.
commit f18d716e52f88aaec81462ccc5754ca07190582e
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date: Fri Sep 26 14:15:07 2014 +0200
Adding POD for Buffer
---
lib/Catmandu/Buffer.pm | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/lib/Catmandu/Buffer.pm b/lib/Catmandu/Buffer.pm
index 87a5880..b635871 100644
--- a/lib/Catmandu/Buffer.pm
+++ b/lib/Catmandu/Buffer.pm
@@ -27,4 +27,71 @@ sub buffer_add {
push @$buffer, @_;
}
+=head1 NAME
+
+Catmandu::Buffer - A base class for modules that need an array buffer
+
+=head1 SYNOPSIS
+
+ package MyPackage;
+
+ use Moo;
+
+ with 'Catmandu::Buffer';
+
+ # Print only when the buffer is full...
+ sub print {
+ my ($self,$str) = @_;
+
+ if ($self->buffer_is_full) {
+ print join "\n" , @{ $self->buffer };
+
+ $self->clear_buffer;
+ }
+
+ $self->buffer_add($str);
+ }
+
+ package main;
+
+ my $x = MyPackage->new;
+
+ for (my $i = 0 ; $i < 1000 ; $i++) {
+ $x->print($x);
+ }
+
+=head1 ATTRIBUTES
+
+=head2 buffer
+
+A ARRAY reference to the content of the buffer.
+
+=head2 buffer_size(MAX)
+
+The maximum size of a buffer.
+
+=head1 METHODS
+
+=head2 clear_buffer()
+
+Empty the buffer.
+
+=head2 buffer_used()
+
+Returns a true value when there is content in the buffer.
+
+=head2 buffer_is_full()
+
+Returns a true value when the buffer has reached its maximum capacity.
+
+=head2 buffer_add($x)
+
+Adds $x to the buffer.
+
+=head1 SEE ALSO
+
+L<Catmandu::Solr::Bag>
+
+=cut
+
1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git
More information about the Pkg-perl-cvs-commits
mailing list