| Mojolicious documentation | Contained in the Mojolicious distribution. |
Mojo::Asset - Asset Base Class
use Mojo::Base 'Mojo::Asset';
Mojo::Asset is an abstract base class for assets.
Mojo::Asset implements the following attributes.
end_rangemy $end = $asset->end_range; $asset = $asset->end_range(8);
Pretend file ends earlier.
start_rangemy $start = $asset->start_range; $asset = $asset->start_range(0);
Pretend file starts later.
Mojo::Asset inherits all methods from Mojo::Base and implements the following new ones.
add_chunk $asset = $asset->add_chunk('foo bar baz');
Add chunk of data to asset.
contains my $position = $asset->contains('bar');
Check if asset contains a specific string.
get_chunkmy $chunk = $asset->get_chunk($offset);
Get chunk of data starting from a specific position.
move_to $asset = $asset->move_to('/foo/bar/baz.txt');
Move asset data into a specific file.
sizemy $size = $asset->size;
Size of asset data in bytes.
slurpmy $string = $file->slurp;
Read all asset data at once.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
| Mojolicious documentation | Contained in the Mojolicious distribution. |
package Mojo::Asset; use Mojo::Base -base; use Carp 'croak'; has 'end_range'; has start_range => 0; # "Marge, it takes two to lie. One to lie and one to listen." sub add_chunk { croak 'Method "add_chunk" not implemented by subclass' } sub contains { croak 'Method "contains" not implemented by subclass' } sub get_chunk { croak 'Method "get_chunk" not implemented by subclass' } sub move_to { croak 'Method "move_to" not implemented by subclass' } sub size { croak 'Method "size" not implemented by subclass' } sub slurp { croak 'Method "slurp" not implemented by subclass' } 1; __END__