NAME
Data::Icon - Data object for icon.
DESCRIPTION
Data object for description of icon. It could be defined as URL with alternate text or as UTF-8 character with colors.
SYNOPSIS
use Data::Icon;
my $obj = Data::Icon->new(%params);
my $alt = $obj->alt;
my $bg_color = $obj->bg_color;
my $char = $obj->char;
my $color = $obj->color;
my $url = $obj->url;
METHODS
new
my $obj = Data::Icon->new(%params);
Constructor.
alt
Alternate text for image icon.
It's optional.
bg_color
Background color for UTF-8 character.
It's optional.
char
Icon character. Could be UTF-8 character. Only one character.
It's optional.
color
Character color.
It's optional.
url
Icon URL.
It's optional.
Returns instance of object.
alt
my $alt = $obj->alt;
Get alternate text for image icon.
Returns string.
bg_color
my $bg_color = $obj->bg_color;
Get background color for UTF-8 character.
Returns string.
char
my $char = $obj->char;
Get icon character.
Returns string.
color
my $color = $obj->color;
Get character color.
Returns CSS color string.
url
my $url = $obj->url;
Get icon URL.
Returns string.
ERRORS
new():
Parameter 'char' don't need parameter 'alt'.
Parameter 'url' don't need parameter 'bg_color'.
Parameter 'url' don't need parameter 'color'.
Parameter 'url' is in conflict with parameter 'char'.
From Mo::utils:
Parameter 'alt' has length greater than '100'.
Value: %s
Parameter 'char' has length greater than '1'.
Value: %s
From Mo::utils::CSS::check_css_color():
Parameter '%s' has bad color name.
Value: %s
Parameter '%s' has bad rgb color (bad hex number).
Value: %s
Parameter '%s' has bad rgb color (bad length).
Value: %s
From Mo::utils::URI::check_location():
Parameter 'url' doesn't contain valid location.
Value: %s
EXAMPLE1
use strict;
use warnings;
use Data::Icon;
my $obj = Data::Icon->new(
'alt' => 'Foo icon',
'url' => 'https://example.com/foo.png',
);
# Print out.
print "Alternate text: ".$obj->alt."\n";
print "Icon URL: ".$obj->url."\n";
# Output:
# Alternate text: Foo icon
# Icon URL: https://example.com/foo.png
EXAMPLE2
use strict;
use warnings;
use Data::Icon;
use Unicode::UTF8 qw(decode_utf8 encode_utf8);
my $obj = Data::Icon->new(
'bg_color' => 'grey',
'char' => decode_utf8('†'),
'color' => 'red',
);
# Print out.
print "Character: ".encode_utf8($obj->char)."\n";
print "CSS color: ".$obj->color."\n";
print "CSS background color: ".$obj->bg_color."\n";
# Output:
# Character: †
# CSS color: red
# CSS background color: grey
DEPENDENCIES
Error::Pure, Mo, Mo::utils, Mo::utils::CSS, Mo::utils::URI.
REPOSITORY
https://github.com/michal-josef-spacek/Data-Icon
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2025 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.02