NAME

Mojo::Buffer - Buffer

SYNOPSIS

use Mojo::Buffer;

my $buffer = Mojo::Buffer->new('foo');
$buffer->add_chunk('bar');
my $foo = $buffer->remove(3);
my $bar = $buffer->empty;

DESCRIPTION

Mojo::Buffer is a simple in-memory buffer.

ATTRIBUTES

buffer_length

my $buffer_length = $buffer->buffer_length;

raw_length

my $raw_length = $buffer->raw_length;

METHODS

Mojo::Buffer inherits all methods from Mojo::Base and implements the following new ones.

new

my $buffer = Mojo::Buffer->new;
my $buffer = Mojo::Buffer->new('foobarbaz');

add_chunk

$buffer = $buffer->add_chunk('foo');

empty

my $string = $buffer->empty;

get_line

my $line = $buffer->get_line;

remove

my $string = $buffer->remove(4);

replace

$buffer = $buffer->replace('foobarbaz');

to_string

my $string = $buffer->to_string;