blib/lib/App/Asciio/stripes/single_stripe.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 53 CC 2 SCAR 9.8
CC
2
Cov
0%
setup
6.0
new
2.0
get_stripes
2.0
CRAP 2.7
1  
2 package App::Asciio::stripes::single_stripe ;
3 use parent qw/App::Asciio::stripes::stripes/ ;
4  
5 use strict;
6 use warnings;
7  
8 use App::Asciio::String ;
9  
10 #-----------------------------------------------------------------------------
11  
12 sub new
13 {
14 my ($class, $element_definition) = @_ ;
15  
16 my $self = bless {}, __PACKAGE__ ;
17  
18 $self->setup($element_definition->{TEXT}) ;
19  
20 return($self) ;
21 }
22  
23 #-----------------------------------------------------------------------------
24  
25 sub setup
26 {
27 my ($self, $text) = @_ ;
28  
29 my $width = 0 ;
30 map {$width = $width < unicode_length($_) ? unicode_length($_) : $width} split("\n", $text) ;
31  
32 my $height = ($text =~ tr[\n][\n]) + 1 ;
33  
34 $self->set
35 (
36 TEXT => $text,
37 WIDTH => $width,
38 HEIGHT => $height,
39 STRIPES => [ {X_OFFSET => 0, Y_OFFSET => 0, WIDTH => $self->{WIDTH}, HEIGHT => $self->{HEIGHT}, TEXT => $text} ],
40 ) ;
41 }
42  
43 #-----------------------------------------------------------------------------
44  
45 sub get_stripes { my ($self) = @_ ; return $self->{STRIPES} ; }
46  
47 #-----------------------------------------------------------------------------
48  
49 sub get_size { my ($self) = @_ ; return($self->{WIDTH}, $self->{HEIGHT}) ; }
50  
51 #-----------------------------------------------------------------------------
52  
53 sub resize
54 {
55 my ($self, $reference_x, $reference_y, $new_x, $new_y) = @_ ;
56  
57 return(0, 0, $self->{WIDTH}, $self->{HEIGHT}) ;
58 }
59  
60 #-----------------------------------------------------------------------------
61  
62 sub get_text { my ($self) = @_ ; return($self->{TEXT}) ; }
63  
64 #-----------------------------------------------------------------------------
65  
66 sub set_text { my ($self, $text) = @_ ; $self->setup($text) ; }
67  
68 #-----------------------------------------------------------------------------
69  
70 1 ;