1Mojo::Asset::File(3)  User Contributed Perl Documentation Mojo::Asset::File(3)
2
3
4

NAME

6       Mojo::Asset::File - File Asset
7

SYNOPSIS

9           use Mojo::Asset::File;
10
11           my $asset = Mojo::Asset::File->new;
12           $asset->add_chunk('foo bar baz');
13           print $asset->slurp;
14
15           my $asset = Mojo::Asset::File->new(path => '/foo/bar/baz.txt');
16           print $asset->slurp;
17

DESCRIPTION

19       Mojo::Asset::File is a container for file assets.
20

ATTRIBUTES

22       Mojo::Asset::File implements the following attributes.
23
24   "cleanup"
25           my $cleanup = $asset->cleanup;
26           $asset      = $asset->cleanup(1);
27
28       Delete file automatically once it's not used anymore.
29
30   "handle"
31           my $handle = $asset->handle;
32           $asset     = $asset->handle(IO::File->new);
33
34       Actual file handle.
35
36   "path"
37           my $path = $asset->path;
38           $asset   = $asset->path('/foo/bar/baz.txt');
39
40       Actual file path.
41
42   "tmpdir"
43           my $tmpdir = $asset->tmpdir;
44           $asset     = $asset->tmpdir('/tmp');
45
46       Temporary directory.
47

METHODS

49       Mojo::Asset::File inherits all methods from Mojo::Asset and implements
50       the following new ones.
51
52   "add_chunk"
53           $asset = $asset->add_chunk('foo bar baz');
54
55       Add chunk of data to asset.
56
57   "contains"
58           my $position = $asset->contains('bar');
59
60       Check if asset contains a specific string.
61
62   "get_chunk"
63           my $chunk = $asset->get_chunk($offset);
64
65       Get chunk of data starting from a specific position.
66
67   "move_to"
68           $asset = $asset->move_to('/foo/bar/baz.txt');
69
70       Move asset data into a specific file.
71
72   "size"
73           my $size = $asset->size;
74
75       Size of asset data in bytes.
76
77   "slurp"
78           my $string = $file->slurp;
79
80       Read all asset data at once.
81

SEE ALSO

83       Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
84
85
86
87perl v5.12.3                      2010-08-12              Mojo::Asset::File(3)
Impressum