NAME
Data::IconText - Work with icon text
VERSION
version v0.01
SYNOPSIS
use Data::IconText;
Allows icon text (single character text icons) to be handled in a nice way.
METHODS
new
my Data::IconText $icontext = Data::IconText->new(unicode => 0x1F981);
# or:
my Data::IconText $icontext = Data::IconText->new(raw => 'X');
Creates a new icon text object.
The icon text is tried to calculate from the options in the following order (first one wins): unicode
, raw
, for
, mediasubtype
, mediatype
, mimetype
, special
. If none is found a fallback is used.
The following options are supported.
unicode
-
The unicode value (e.g.
0x1F981
). May also be a string in standard format (e.g.'U+1F981'
). raw
-
The character as a raw perl string. Must be exactly one character long.
for
-
An object to find the icon text for. Currently supported are objects of the following packages: File::FStore::File, File::Information::Base, Data::TagDB::Tag, Data::URIID::Base, Data::Identifier.
If the value is a plain string it is tried to be converted to a Data::Identifier first.
If a Data::Identifier is passed, a lookup is performed using the passed subobjects.
mediasubtype
-
The media subtype (e.g.
audio/flac
). Only values assigned by IANA are valid. mediatype
-
The media type (e.g.
audio
). Only values assigned by IANA are valid. mimetype
-
A low quality value that looks like a mediasubtype (e.g. provided via HTTP's
Content-type
or by type guessing modules). special
-
One of:
directory
,parent-directory
,regular
,regular-not-in-pool
. for_version
-
The version of this module to use the rules for calculation of the icon text from. Defaults to the current version of this module. If a given version is not supported, this method
die
s.
Additionally subobjects can be attached:
db
-
A Data::TagDB object.
extractor
-
A Data::URIID object.
fii
-
A File::Information object.
store
-
A File::FStore object.
weak
-
Marks the value for all subobjects as weak. If only a specific one needs needs to be weaken use "attach".
unicode
my $unicode = $icontext->unicode;
This returns the numeric unicode value (e.g. 0x1F981) of the icon text.
as_string
my $str = $icontext->as_string;
Gets the icon text as a perl string.
for_version
my $version = $icontext->for_version;
The version of this module from which the rules where used.
as
my $xxx = $icontext->as($as, %opts);
This is a proxy for "as" in Data::Identifier.
This method automatically adds all attached subobjects (if not given via %opts
).
ise
my $ise = $icontext->ise(%opts);
THis is a proxy for "ise" in Data::Identifier.
attach
$icontext->attach(key => $obj, ...);
# or:
$icontext->attach(key => $obj, ..., weak => 1);
Attaches objects of the given type. Takes the same list of objects as "new".
If an object is allready attached for the given key this method die
s unless the object is actually the same.
If weak
is set to a true value the object reference becomes weak.
Returns itself.
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)