The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Nuvol::Item - Item in a drive

SYNOPSIS

    use Nuvol;
    my $drive = Nuvol::connect($configfile)->drive($drive_path);
    my $item  = $drive->item($path);

    $item->drive;
    $item->exists;
    $item->is_file;
    $item->is_folder;
    $item->realpath;
    $item->type;

    # files
    $item->copy_from;
    $item->copy_to;
    $item->spurt;
    $item->slurp;
    $item->download_url;
    $item->remove;

    # folders
    $item->make_path;
    $item->remove_tree;

    # metadata
    $item->description;
    $item->id;
    $item->metadata;
    $item->name;

DESCRIPTION

Nuvol::Item is an item in a drive. It can be either a file or a folder.

The syntax for drive items is oriented at Mojo::File, so anyone familiar with this module will recognize most of the methods.

CONSTRUCTOR

via Nuvol::Drive

    use Nuvol;
    $drive = Nuvol::Connector->new($configfile)->drive(%drive_path);

    $file   = $connector->item('/path/to/file');
    $folder = $connector->item('/path/to/folder/');

In daily use a Nuvol::Item is created with "item" in Nuvol::Drive. Paths must be absolute (starting with a slash). Paths with trailing slash are interpreted as folders, without slash as files.

new

    $item = Nuvol::Item->new($drive, {id       => $id});
    $item = Nuvol::Item->new($drive, {metadata => $metadata});
    $item = Nuvol::Item->new($drive, {path     => $path});

The internal constructor can be used if the id or metadata of the item are known.

METHODS

If a Nuvol::Item is a file it inherits the following methods from Nuvol::Role::File:

copy_from
copy_to
spurt
slurp
download_url
remove

A folder inherits the following methods from Nuvol::Role::Folder:

make_path
remove_tree

All item types inherit the following methods from Nuvol::Role::Metadata:

description
id
metadata
name
url

drive

    $drive = $item->drive;

Getter for the drive. Returns a Nuvol::Drive.

exists

    $bool = $item->exists;

Checks if the item exists.

is_file

    $bool = $item->is_file;

Returns a true value if the "type" of the item is File.

is_folder

    $bool = $item->is_folder;

Returns a true value if the "type" of the item is Folder.

realpath

    $realpath = $item->realpath;

Getter for the full path of the item relative to its drive. Returns a Mojo::Path.

    # '/path%20to/item'
    say $item->realpath;

    # '/path to/item'
    say $item->realpath->to_route;

Real paths are URL escaped. "to_route" in Mojo::Path returns the unescaped string.

type

    $type = $item->type;

Getter for the type, can be File or Folder.

SEE ALSO

Mojo::File, Nuvol::Drive, Nuvol::Role::File, Nuvol::Role::Folder.