NAME

Sweet::File

SYNOPSIS

use Sweet::File;

my $file1 = Sweet::File->new(
    dir => '/path/to/dir',
    name => 'foo',
);

my $file2 = Sweet::File->new(path => '/path/to/file');

ATTRIBUTES

dir

extension

name

path

METHODS

copy_to_dir

does_not_exists

erase

has_zero_size

is_a_plain_file

is_executable

is_writable

line

my $line1 = $file->line(0);
my $line2 = $file->line(1);
my $line3 = $file->line(2);

lines

for my $line ( $file->lines ) {
    chomp $line;
    $line =~ s/foo/bar/;
    say $line;
}

num_lines

say $file->num_lines if $file->is_a_plain_file;

_read_file

Reads the file contents using File::Slurp read_file function.

Defaults to

sub { read_file( shift->path, array_ref => 1 ) }

and must return an array_ref of strings containing file lines.