File Coverage

blib/lib/BorderStyleBase.pm
Criterion Covered Total %
statement 21 27 77.7
branch 8 14 57.1
condition n/a
subroutine 5 5 100.0
pod 0 3 0.0
total 34 49 69.3


line stmt bran cond sub pod time code
1             package BorderStyleBase;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-06-19'; # DATE
5             our $DIST = 'BorderStyleBase'; # DIST
6             our $VERSION = '0.004'; # VERSION
7              
8 1     1   468 use strict 'subs', 'vars';
  1         2  
  1         31  
9             #use warnings;
10 1     1   5 use parent 'BorderStyleBase::Constructor';
  1         2  
  1         5  
11              
12             sub get_struct {
13 3     3 0 7 my $self_or_class = shift;
14 3 50       7 if (ref $self_or_class) {
15 3         3 \%{"$self_or_class->{orig_class}::BORDER"};
  3         12  
16             } else {
17 0         0 \%{"$self_or_class\::BORDER"};
  0         0  
18             }
19             }
20              
21             sub get_args {
22 1     1 0 9 my $self = shift;
23 1         6 $self->{args};
24             }
25              
26             sub get_border_char {
27 2     2 0 13 my ($self, $y, $x, $n, $args) = @_;
28 2 100       5 $n = 1 unless defined $n;
29              
30 2         7 my $bs_struct = $self->get_struct;
31              
32 2         5 my $c = $bs_struct->{chars}[$y][$x];
33 2 50       5 return unless defined $c;
34              
35 2 50       6 if (ref $c eq 'CODE') {
36 0         0 my $c2 = $c->($self, $y, $x, $n, $args);
37 0 0       0 if (ref $c2 eq 'CODE') {
38 0         0 die "Border character ($y, $x) of style $self->{orig_class} returns coderef, ".
39             "which after called still returns a coderef";
40             }
41 0         0 return $c2;
42             } else {
43 2 100       6 $c = $c x $n if $n != 1;
44 2 50       5 $c = "\e(0$c\e(B" if $bs_struct->{box_chars};
45             }
46 2         10 $c;
47             }
48              
49             1;
50             # ABSTRACT: A suitable base class for most BorderStyle::* modules
51              
52             __END__