| 1 | package Data::Icon; | ||
| 2 | |||
| 3 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 8 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 0 | ▶ | use Error::Pure qw(err); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | use Mo qw(build is); | ||
| 8 | use Mo::utils 0.05 qw(check_length); | ||
| 9 | use Mo::utils::CSS 0.03 qw(check_css_color); | ||
| 10 | use Mo::utils::URI 0.02 qw(check_location); | ||
| 11 | |||
| 12 | our $VERSION = 0.02; | ||
| 13 | |||
| 14 | has alt => ( | ||
| 15 | is => 'ro', | ||
| 16 | ); | ||
| 17 | |||
| 18 | has bg_color => ( | ||
| 19 | is => 'ro', | ||
| 20 | ); | ||
| 21 | |||
| 22 | has char => ( | ||
| 23 | is => 'ro', | ||
| 24 | ); | ||
| 25 | |||
| 26 | has color => ( | ||
| 27 | is => 'ro', | ||
| 28 | ); | ||
| 29 | |||
| 30 | has url => ( | ||
| 31 | is => 'ro', | ||
| 32 | ); | ||
| 33 | |||
| 34 | sub BUILD { | ||
| 35 | my $self = shift; | ||
| 36 | |||
| 37 | # Check alt. | ||
| 38 | check_length($self, 'alt', 100); | ||
| 39 | |||
| 40 | # Check bg_color. | ||
| 41 | check_css_color($self, 'bg_color'); | ||
| 42 | |||
| 43 | # Check char. | ||
| 44 | check_length($self, 'char', 1); | ||
| 45 | |||
| 46 | # Check color. | ||
| 47 | check_css_color($self, 'color'); | ||
| 48 | |||
| 49 | # Check url. | ||
| 50 | check_location($self, 'url'); | ||
| 51 | # TODO Check image | ||
| 52 | |||
| 53 | if (defined $self->{'char'} && defined $self->{'url'}) { | ||
| 54 | err "Parameter 'url' is in conflict with parameter 'char'."; | ||
| 55 | } | ||
| 56 | |||
| 57 | if (defined $self->{'char'} && defined $self->{'alt'}) { | ||
| 58 | err "Parameter 'char' don't need parameter 'alt'."; | ||
| 59 | } | ||
| 60 | |||
| 61 | if (defined $self->{'url'}) { | ||
| 62 | if (defined $self->{'color'}) { | ||
| 63 | err "Parameter 'url' don't need parameter 'color'."; | ||
| 64 | } | ||
| 65 | if (defined $self->{'bg_color'}) { | ||
| 66 | err "Parameter 'url' don't need parameter 'bg_color'."; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | return; | ||
| 71 | } | ||
| 72 | |||
| 73 | 1; | ||
| 74 | |||
| 75 | __END__ | ||