Travis Build Status Kritika Analysis Status Coverage Status

NAME

Mojo::File::Role::Extension - Access Mojo::File filename extensions

SYNOPSIS

$file = Mojo::File->new('/some/path.txt')->with_roles('+Extension');
# .txt
$file->extension;
# /some/path.csv
$file->switch_extension('.csv');

DESCRIPTION

Add file extension access and modifying behaviour to Mojo::File.

METHODS

The Mojo::File::Role::Extension role adds the following methods to a Mojo::File once composed.

extension

# .txt
$file->extension;

Readonly access to the file extension of the file or directory.

extension_parts

# ['.tar', '.gz']
$file->extension_parts;

Readonly access to the file extension(s) of the file or directory. The parts are returned as a Mojo::Collection of strings.

moniker

# path
$file->moniker;

Readonly access to the short name of the file, i.e. prior to the "extension".

switch_extension

# /some/path.csv
$file->switch_extension('.csv');

Change the extension of the Mojo::File, retaining the rest of the path and return a new Mojo::File object.

COPYRIGHT & LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Roy Storey - <kiwiroy@cpan.org>