| 1 | package Forest::Tree::Writer::ASCIIWithBranches; | ||||||||||||
| 2 | 2 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 2 | our $VERSION = '0.10'; | |||||||||||
| 5 | 2 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||
| 6 | |||||||||||||
| 7 | 2 | with 'Forest::Tree::Writer', | |||||||||||
| 8 | 'Forest::Tree::Roles::HasNodeFormatter'; | ||||||||||||
| 9 | |||||||||||||
| 10 | 2 | ▶ | sub as_string { | ||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 11 | 2 | my ($self) = @_; | |||||||||||
| 12 | |||||||||||||
| 13 | 2 | my $out = ''; | |||||||||||
| 14 | 2 | my @vert_dashes; | |||||||||||
| 15 | |||||||||||||
| 16 | 22 | ▶ | $self->tree->traverse(sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 22 | my $t = shift; | |||||||||||
| 18 | 22 | $out .= $self->_process_node($t, \@vert_dashes); | |||||||||||
| 19 | 2 | }); | |||||||||||
| 20 | |||||||||||||
| 21 | 2 | return $out; | |||||||||||
| 22 | } | ||||||||||||
| 23 | |||||||||||||
| 24 | 22 | ▶ | sub _process_node { | ||||||||||
|
Subroutine
_process_node: called CC=6 SCAR=18.0
| |||||||||||||
| 25 | 22 | my ($self, $t, $vert_dashes) = @_; | |||||||||||
| 26 | |||||||||||||
| 27 | 22 | my $depth = $t->depth; | |||||||||||
| 28 | 22 | ▶ | my $sibling_count = $t->is_root ? 1 : $t->parent->child_count; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | |||||||||||||
| 30 | my @indent = map { | ||||||||||||
| 31 | 22 | ▶ | $vert_dashes->[$_] || " " | ||||||||||
|
Condition50%1/2
$vert_dashes->[$_] || ' '
MC/DC0%0/1
$vert_dashes->[$_] || ' '
$vert_dashes->[$_]
Truth table50%1/2
A
A= $vert_dashes->[$_]
| |||||||||||||
| 32 | } 0 .. $depth - 1; | ||||||||||||
| 33 | |||||||||||||
| 34 | 22 | ▶ | @$vert_dashes = ( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | @indent, | ||||||||||||
| 36 | ($sibling_count == 1 | ||||||||||||
| 37 | ? (" ") | ||||||||||||
| 38 | : (" |")) | ||||||||||||
| 39 | ); | ||||||||||||
| 40 | |||||||||||||
| 41 | 22 | ▶ | if ($sibling_count == ($t->get_index_in_siblings + 1)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 14 | $vert_dashes->[$depth] = " "; | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 22 | ▶ | return ((join "" => @indent[1 .. $#indent]) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | . ($depth ? " |---" : "") | ||||||||||||
| 47 | . $self->format_node($t) | ||||||||||||
| 48 | . "\n"); | ||||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 52 | |||||||||||||
| 53 | 2 | ▶ | no Moose; 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 54 | |||||||||||||
| 55 | __END__ | ||||||||||||