| 1 | package BorderStyleRole::Source::Hash; | ||||||||||||
| 2 | |||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 3 | ▶ | use 5.010001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 3 | ▶ | use Role::Tiny; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | ▶ | use Role::Tiny::With; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 3 | with 'BorderStyleRole::Spec::Basic'; | |||||||||||
| 8 | |||||||||||||
| 9 | 3 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||
| 10 | 3 | our $DATE = '2023-07-14'; # DATE | |||||||||||
| 11 | 3 | our $DIST = 'BorderStyle'; # DIST | |||||||||||
| 12 | 3 | our $VERSION = '3.0.3'; # VERSION | |||||||||||
| 13 | |||||||||||||
| 14 | 0 | ▶ | sub get_border_char { | ||||||||||
|
Subroutine
get_border_char: not called CC=12 SCAR=48.6
Pod
undocumented
| |||||||||||||
| 15 | 0 | my ($self, %args) = @_; | |||||||||||
| 16 | |||||||||||||
| 17 | 0 | ▶ | my $char = $args{char} or die "Please specify 'char'"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 0 | ▶ | my $repeat = $args{repeat} // 1; | ||||||||||
|
Condition0%0/2
$args{"repeat"} // 1
MC/DC0%0/1
$args{"repeat"} // 1
$args{"repeat"}
Truth table0%0/2
A
A= $args{"repeat"}
| |||||||||||||
| 19 | |||||||||||||
| 20 | 3 | ▶ | no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | |||||||||||||
| 22 | #use DD; dd \%args; | ||||||||||||
| 23 | |||||||||||||
| 24 | 0 | my $_char; | |||||||||||
| 25 | |||||||||||||
| 26 | # @MULTI_CHARS | ||||||||||||
| 27 | { | ||||||||||||
| 28 | 0 | ▶ | last unless @{"$self->{orig_class}::MULTI_CHARS"}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 0 | my $i = -1; | |||||||||||
| 30 | ENTRY: | ||||||||||||
| 31 | 0 | for my $entry (@{"$self->{orig_class}::MULTI_CHARS"}) { | |||||||||||
| 32 | 0 | $i++; | |||||||||||
| 33 | #use DD; print "entry: "; dd $entry; | ||||||||||||
| 34 | 0 | for my $criteria_key (keys %$entry) { | |||||||||||
| 35 | 0 | ▶ | next unless $criteria_key =~ /^for_/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | #print "D:criteria_key=$criteria_key "; | ||||||||||||
| 37 | 0 | ▶ | next ENTRY unless defined $args{$criteria_key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | 0 | ▶ | next ENTRY unless $entry->{$criteria_key} == $args{$criteria_key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 39 | } | ||||||||||||
| 40 | #print "D:entry[$i] matches criteria\n"; | ||||||||||||
| 41 | # the entry matches the criteria | ||||||||||||
| 42 | die "Unknown (in \$MULTI_CHARS[$i]) border character requested: '$char'" | ||||||||||||
| 43 | 0 | ▶ | unless defined ($_char = $entry->{chars}{$char}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 0 | goto PROCESS; | |||||||||||
| 45 | } # for $entry | ||||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | # %CHARS | ||||||||||||
| 49 | { | ||||||||||||
| 50 | 0 | my $chars = \%{"$self->{orig_class}::CHARS"}; | |||||||||||
| 51 | die "Unknown (in \%CHARS) border character requested: '$char'" | ||||||||||||
| 52 | 0 | ▶ | unless defined ($_char = $chars->{$char}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | 0 | goto PROCESS; | |||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | PROCESS: | ||||||||||||
| 57 | # process coderef border char | ||||||||||||
| 58 | 0 | ▶ | if (ref $_char eq 'CODE') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | 0 | return $_char->(%args); | |||||||||||
| 60 | } else { | ||||||||||||
| 61 | #print "D:char=<$_char>\n"; | ||||||||||||
| 62 | 0 | return $_char x $repeat; | |||||||||||
| 63 | } | ||||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 3 | 1; | |||||||||||
| 67 | # ABSTRACT: Get border characters from %CHARS (or @MULTI_CHARS) package variable | ||||||||||||
| 68 | |||||||||||||
| 69 | __END__ | ||||||||||||