Catmandu::Buffer(3pm)

Catmandu::Buffer3pm

A base class for modules that need an array buffer

Usage

    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);
    }

Attributes

buffer

A ARRAY reference to the content of the buffer.

buffer_size(MAX)

The maximum size of a buffer.

Methods

clear_buffer()

Empty the buffer.

buffer_used()

Returns a true value when there is content in the buffer.

buffer_is_full()

Returns a true value when the buffer has reached its maximum capacity.

buffer_add($x)

Adds $x to the buffer.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From libcatmandu-perl 1.2024-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.