Data-IconText

 view release on metacpan or  search on metacpan

lib/Data/IconText.pm  view on Meta::CPAN

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# ABSTRACT: Work with icon text
 
 
use v5.20;
use strict;
 
use Carp;
use Scalar::Util qw(looks_like_number weaken);
use Data::Identifier v0.12;
 
use constant {
    WK_UNICODE_CP               => Data::Identifier->new(uuid => '5f167223-cc9c-4b2f-9928-9fe1b253b560')->register, # unicode-code-point
    WK_ASCII_CP                 => Data::Identifier->new(uuid => 'f4b073ff-0b53-4034-b4e4-4affe5caf72c')->register, # ascii-code-point
    WK_FREEDESKTOP_ICON_NAME    => Data::Identifier->new(uuid => '560906df-ebd1-41f6-b510-038b30522051')->register, # freedesktop-icon-name
};
 
use overload '""' => sub {$_[0]->as_string};

lib/Data/IconText.pm  view on Meta::CPAN

666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
sub attach {
    my ($self, %opts) = @_;
    my $weak = delete $opts{weak};
 
    foreach my $key (keys %_types) {
        my $v = delete $opts{$key};
        next unless defined $v;
        croak 'Invalid type for key: '.$key unless eval {$v->isa($_types{$key})};
        $self->{$key} //= $v;
        croak 'Missmatch for key: '.$key unless $self->{$key} == $v;
        weaken($self->{$key}) if $weak;
    }
 
    croak 'Stray options passed' if scalar keys %opts;
 
    return $self;
}
 
# ---- Private helpers ----
sub _find_for_version_info {
    my ($self) = @_;

lib/Data/IconText.pm  view on Meta::CPAN

846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
A L<File::Information> object.
 
=item C<store>
 
A L<File::FStore> object.
 
=item C<weak>
 
Marks the value for all subobjects as weak.
If only a specific one needs needs to be weaken use L</attach>.
 
=back
 
=head2 unicode
 
    my $unicode = $icontext->unicode;
 
This returns the numeric unicode value (e.g. 0x1F981) of the icon text.
If there is no single value associated with the icon text, this method C<die>s.



( run in 0.313 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )