Data-URIID
view release on metacpan or search on metacpan
lib/Data/URIID/Barcode.pm view on Meta::CPAN
A list (arrayref) of values to be used as data barcodes to be generated.
If given C<from> must be C<undef>.
=item C<template>
A template (see L<perlfunc/sprintf>) that is applied to each value in C<values>.
Defaults to no transformation.
If defined, must not be used with values that are references.
=item C<type>
The type of the barcode to be used with C<values>.
=back
=head2 new
my Data::URIID::Barcode $barcode = Data::URIID::Barcode->new(type => ..., data => ..., [ %opts ] );
# or:
my Data::URIID::Barcode $barcode = Data::URIID::Barcode->new(from => ..., [ %opts ] );
This method creates a new barcode object.
The following options are supported:
=over
=item C<data>
The raw data of the barcode.
=item C<extractor>
optionally, an instance of L<Data::URIID>.
=item C<from>
optionally, an instance of another object to read the values from.
Depending on the given object the non-optional values might become optional.
Currently the following types are supported:
L<Data::URIID::Base>,
L<Data::Identifier>,
L<URI>.
Other types might be supported as well.
=item C<type>
The type of the barcode. One of C<TYPE_*>.
Future versions of this module might improve this definition.
=back
=head2 data
my $data = $barcode->data;
Returns the data of the barcode.
The returned value might differ from the value passed to L</new> as it might have been normalised, decoded (character set), or otherwise altered.
No options are supported. However the options C<default>, and C<no_defaults> are ignored.
=head2 type
my $type = $barcode->type;
Returns the type of the barcode.
The returned value might differ from the value passed to L</new> as it might have been normalised, replaced with a cached reference, or otherwise altered.
No options are supported. However the options C<default>, and C<no_defaults> are ignored.
See L</has_type> for a more convenient method.
=head2 has_type
my $bool = $barcode->has_type(Data::URIID::Barcode->TYPE_*);
# or:
my $bool = $barcode->has_type([Data::URIID::Barcode->TYPE_*, ...]);
Returns whether or not this barcode is of the given type.
If the type is given as an arrayref then it is checked if the type matches any of the elements.
No options are supported. However the options C<default>, and C<no_defaults> are ignored.
=head2 render
$barcode->render(filename => ...);
Render the barcode as a image file.
B<Experimental:>
This method is experimental. It may change completly or may be removed on future versions.
B<Note:>
Currently this method exports as PNG. Later versions might support other formats.
=head2 type_info
my @info = Data::URIID::Barcode->type_info;
# or:
my @info = Data::URIID::Barcode->type_info($type0, $type1, ...);
# or:
my $info = Data::URIID::Barcode->type_info($type);
# or:
my $info = $barcode->type_info;
Returns information on a barcode type.
If called in list context returns a list.
If called in scalar context returns the only one result (or C<die>s if there is not exactly one result).
Takes a list of C<TYPE_*> constants as arguments.
If the provided value is not a C<TYPE_*> constant the value is checked against an internal alias list.
If no types are given, returns information for all known types (if called on the package) or
for the type of the current barcode (if called on an instance).
Each element returned is an hash reference containing the following keys:
( run in 0.709 second using v1.01-cache-2.11-cpan-39bf76dae61 )