Minor changes, add 2 functions just to clarify the code
parent
982d9215bb
commit
3d2c1438c8
Binary file not shown.
Binary file not shown.
|
@ -2,23 +2,42 @@ package MyWrapper;
|
||||||
use GD;
|
use GD;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use 5.16.0;
|
use 5.14.2;
|
||||||
use Moo;
|
use Moo;
|
||||||
use MooX::Options;
|
use MooX::Options;
|
||||||
|
|
||||||
has couleurs => ( is => 'ro', builder => '_build_colors' );
|
has couleurs => ( is => 'ro', builder => '_build_colors' );
|
||||||
|
|
||||||
|
option message => ( is => 'rw',
|
||||||
option mess => ( is => 'rw',
|
doc => 'message',
|
||||||
doc => 'message', format => 's', default => sub { 'message à afficher' } );
|
short => 'm',
|
||||||
|
format => 's', default => sub { 'message à afficher' }
|
||||||
|
);
|
||||||
option couleur_externe => ( is => 'rw',
|
option couleur_externe => ( is => 'rw',
|
||||||
doc => 'couleur externe', format => 's', default => sub { 'bleu' });
|
doc => 'couleur externe',
|
||||||
|
short => 'ce',
|
||||||
|
format => 's', default => sub { 'bleu' }
|
||||||
|
);
|
||||||
option couleur_interne => ( is => 'rw',
|
option couleur_interne => ( is => 'rw',
|
||||||
doc => 'couleur interne', format => 's' );
|
doc => 'couleur interne',
|
||||||
|
short => 'ci',
|
||||||
|
format => 's', default => sub { 'blanc' }
|
||||||
|
);
|
||||||
option couleur_background => ( is => 'rw' ,
|
option couleur_background => ( is => 'rw' ,
|
||||||
doc => 'couleur du fond (écriture)', format => 's');
|
doc => 'couleur du fond (écriture)',
|
||||||
|
short => 'cb',
|
||||||
|
format => 's', default => sub { 'noir' }
|
||||||
|
);
|
||||||
|
option taille_x => ( is => 'rw',
|
||||||
|
doc => 'taille X', format => 'i',
|
||||||
|
short => 'x',
|
||||||
|
default => sub { 150 }
|
||||||
|
);
|
||||||
|
option taille_y => ( is => 'rw',
|
||||||
|
doc => 'taille Y', format => 'i',
|
||||||
|
short => 'y',
|
||||||
|
default => sub { 50 }
|
||||||
|
);
|
||||||
sub _build_colors {
|
sub _build_colors {
|
||||||
{
|
{
|
||||||
bleu => [0, 0, 255],
|
bleu => [0, 0, 255],
|
||||||
|
@ -29,24 +48,36 @@ sub _build_colors {
|
||||||
gris => [140, 140, 140]
|
gris => [140, 140, 140]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
sub tests {
|
sub afficher_couleurs {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my %couleurs = %{$self->couleurs};
|
my %couleurs = %{$self->couleurs};
|
||||||
|
|
||||||
say "mess : " . $self->mess;
|
|
||||||
say "couleur_externe : " . $self->couleur_externe;
|
|
||||||
say "Cette couleur n'existe pas !" unless exists $couleurs{$self->couleur_externe};
|
|
||||||
say "couleurs : " . join( ', ' , keys %couleurs) ;
|
say "couleurs : " . join( ', ' , keys %couleurs) ;
|
||||||
while( my ($key , $value) = each %couleurs)
|
while( my ($key , $value) = each %couleurs)
|
||||||
{
|
{
|
||||||
say "La couleur $key est : " . join(', ' , @$value);
|
say "La couleur $key est : " . join(', ' , @$value);
|
||||||
}
|
}
|
||||||
# say "couleur_interne : " . $self->couleur_interne;
|
}
|
||||||
# say "couleur_background : " . $self->couleur_background;
|
sub afficher_valeurs_actuelles {
|
||||||
|
my ($self) = @_;
|
||||||
|
say "Message : " . $self->message;
|
||||||
|
say "couleur_interne : " . $self->couleur_interne;
|
||||||
|
say "couleur_externe : " . $self->couleur_externe;
|
||||||
|
say "couleur_background : " . $self->couleur_background;
|
||||||
|
say "taille_x : " . $self->taille_x;
|
||||||
|
say "taille_y : " . $self->taille_y;
|
||||||
|
}
|
||||||
|
sub tests {
|
||||||
|
my ($self) = @_;
|
||||||
|
my %couleurs = %{$self->couleurs};
|
||||||
|
|
||||||
|
say "message : " . $self->message;
|
||||||
|
say "couleur_externe : " . $self->couleur_externe;
|
||||||
|
say "Cette couleur n'existe pas !" unless exists $couleurs{$self->couleur_externe};
|
||||||
}
|
}
|
||||||
sub run {
|
sub run {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
say "RUN !!!";
|
#$self->afficher_couleurs ;
|
||||||
|
$self->afficher_valeurs_actuelles;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -3,6 +3,6 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use MyWrapper;
|
use MyWrapper;
|
||||||
my $wrapper = MyWrapper->new_with_options();
|
my $wrapper = MyWrapper->new_with_options();
|
||||||
$wrapper->tests();
|
#$wrapper->tests();
|
||||||
$wrapper->run();
|
$wrapper->run();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue