NAME
METS::Files - Class for METS files manipulation.
SYNOPSIS
use METS::Files;
my $obj = METS::Files->new(
'mets_data' => $mets_data,
);
my @files = $obj->get_use_files($use);
my @types = $obj->get_use_types;
METHODS
"new()"
Constructor.
* "mets_data"
METS data.
Parameter is required.
Default value is undef.
"get_use_files($use)"
Get "USE" files.
Returns array with files.
"get_use_types()"
Get "USE" types.
Returns array with types.
ERRORS
new():
Parameter 'mets_data' is required.
From Class::Utils::set_params():
Unknown parameter '%s'.
EXAMPLE1
use strict;
use warnings;
use Data::Printer;
use METS::Files;
use Perl6::Slurp qw(slurp);
# Arguments.
if (@ARGV < 1) {
print STDERR "Usage: $0 mets_file\n";
exit 1;
}
my $mets_file = $ARGV[0];
# Get mets data.
my $mets_data = slurp($mets_file);
# Object.
my $obj = METS::Files->new(
'mets_data' => $mets_data,
);
# Get files.
my $files_hr;
foreach my $use ($obj->get_use_types) {
$files_hr->{$use} = [$obj->get_use_files($use)];
}
# Dump to output.
p $files_hr;
# Output without arguments like:
# Usage: __SCRIPT__ mets_file
EXAMPLE2
use strict;
use warnings;
use Data::Printer;
use METS::Files;
# Example METS data.
my $mets_data = <<'END';
END
# Object.
my $obj = METS::Files->new(
'mets_data' => $mets_data,
);
# Get files.
my $files_hr;
foreach my $use ($obj->get_use_types) {
$files_hr->{$use} = [$obj->get_use_files($use)];
}
# Dump to output.
p $files_hr;
# Output:
# \ {
# Images [
# [0] "file://./003855/003855r.tif",
# [1] "file://./003855/003855v.tif"
# ],
# PDF [
# [0] "file://./003855/003855r.pdf",
# [1] "file://./003855/003855v.pdf"
# ]
# }
DEPENDENCIES
Class::Utils, Error::Pure, METS::Parse::Simple, Readonly.
REPOSITORY
AUTHOR
Michal Josef Špaček
LICENSE AND COPYRIGHT
© 2015-2022 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.02