File Coverage

blib/lib/Tree/Visualize/ASCII/Connectors/Diagonal/LeftRightConnector.pm
Criterion Covered Total %
statement 28 28 100.0
branch 6 8 75.0
condition 8 16 50.0
subroutine 6 6 100.0
pod 2 2 100.0
total 50 60 83.3


line stmt bran cond sub pod time code
1              
2             package Tree::Visualize::ASCII::Connectors::Diagonal::LeftRightConnector;
3              
4 2     2   1359 use strict;
  2         5  
  2         66  
5 2     2   11 use warnings;
  2         3  
  2         55  
6              
7 2     2   11 use Tree::Visualize::ASCII::BoundingBox;
  2         5  
  2         169  
8              
9             our $VERSION = '0.01';
10              
11 2     2   11 use base qw(Tree::Visualize::Connector::IConnector);
  2         4  
  2         957  
12              
13             sub drawLeftConnector {
14 7     7 1 8 my ($self, $current, $left, $right) = @_;
15 7         21 $self->checkArgs($current, $left);
16            
17 7         8 my $left_spacing = 1;
18 7 50 33     49 if (defined($right) && ref($right) && UNIVERSAL::isa($right, "Tree::Visualize::ASCII::BoundingBox")) {
      33        
19 7   100     17 $left_spacing = ($right->height() - $current->height()) || 1;
20             }
21 7 100       13 $left_spacing++ unless $left_spacing == 1;
22 7         18 my $connectors = (" " x int($current->width() / 2)) . "|" . (" " x int($current->width() / 2));
23 7         26 return Tree::Visualize::ASCII::BoundingBox->new("$connectors\n" x $left_spacing);
24             }
25              
26             sub drawRightConnector {
27 7     7 1 10 my ($self, $current, $right, $left) = @_;
28 7         16 $self->checkArgs($current, $right);
29            
30 7         10 my $right_spacing = 1;
31 7 50 33     46 if (defined($left) && ref($left) && UNIVERSAL::isa($left, "Tree::Visualize::ASCII::BoundingBox")) {
      33        
32 7   100     15 $right_spacing = ($left->width() - $current->width()) || 1;
33             }
34 7 100       13 $right_spacing++ unless $right_spacing == 1;
35 7         10 my $space = (" " x $right_spacing);
36 7         20 return Tree::Visualize::ASCII::BoundingBox
37             ->new(
38             ("$space\n" x int($current->height() / 2)) .
39             ("-" x $right_spacing)
40             );
41             }
42              
43             1;
44              
45             __END__