| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::SuddenlyDeath; | 
| 2 | 3 |  |  | 3 |  | 28459 | use strict; | 
|  | 3 |  |  |  |  | 8 |  | 
|  | 3 |  |  |  |  | 95 |  | 
| 3 | 3 |  |  | 3 |  | 15 | use warnings; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 78 |  | 
| 4 | 3 |  |  | 3 |  | 1054 | use utf8; | 
|  | 3 |  |  |  |  | 17 |  | 
|  | 3 |  |  |  |  | 12 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 3 |  |  | 3 |  | 2456 | use parent 'Exporter'; | 
|  | 3 |  |  |  |  | 900 |  | 
|  | 3 |  |  |  |  | 16 |  | 
| 7 | 3 |  |  | 3 |  | 2500 | use Text::VisualWidth::UTF8; | 
|  | 3 |  |  |  |  | 43063 |  | 
|  | 3 |  |  |  |  | 131 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our @EXPORT = qw/ sudden_death sudden_death_single /; | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 3 |  |  | 3 |  | 2243 | use version; our $VERSION = '0.09'; | 
|  | 3 |  |  |  |  | 5723 |  | 
|  | 3 |  |  |  |  | 14 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub _generator { | 
| 14 | 8 |  |  | 8 |  | 10 | my $decoded_str = shift; | 
| 15 | 8 |  |  |  |  | 42 | my @decoded_lines = split /\n/, $decoded_str; | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 8 |  |  |  |  | 13 | my $max_length = 0; | 
| 18 | 10 |  |  |  |  | 37 | $max_length = $_ > $max_length ? $_ : $max_length | 
| 19 | 8 | 100 |  |  |  | 15 | for map {Text::VisualWidth::UTF8::width($_)} @decoded_lines; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 8 |  |  |  |  | 78 | my $ascii = []; | 
| 22 | 8 |  |  |  |  | 20 | my $frame_length = ($max_length + 2) / 2; | 
| 23 | 8 |  |  |  |  | 8 | push @{$ascii}, '_' . '人' x $frame_length . '_'; | 
|  | 8 |  |  |  |  | 35 |  | 
| 24 | 8 |  |  |  |  | 16 | for my $line (@decoded_lines) { | 
| 25 | 10 |  |  |  |  | 25 | my $str_length = $max_length - Text::VisualWidth::UTF8::width($line); | 
| 26 | 10 |  |  |  |  | 53 | my ($left, $right) = map{' ' x $_} ($str_length / 2, $str_length / 2); | 
|  | 20 |  |  |  |  | 48 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 10 | 100 |  |  |  | 31 | $left = $str_length % 2 != 0 ? $left . ' ' : $left; | 
| 29 | 10 |  |  |  |  | 13 | push @{$ascii}, '> ' . $left . $line . $right . ' <'; | 
|  | 10 |  |  |  |  | 50 |  | 
| 30 |  |  |  |  |  |  | } | 
| 31 | 8 |  |  |  |  | 12 | push @{$ascii}, ' ̄' . '^Y' x ($frame_length - 1) . '^ ̄'; | 
|  | 8 |  |  |  |  | 29 |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 8 |  |  |  |  | 22 | return $ascii; | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub sudden_death { | 
| 37 | 4 |  |  | 4 | 1 | 2951 | my $string = shift; | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 4 |  |  |  |  | 11 | my $ascii = _generator($string); | 
| 40 | 4 |  |  |  |  | 6 | return join "\n", @{$ascii}; | 
|  | 4 |  |  |  |  | 17 |  | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub sudden_death_single { | 
| 44 | 4 |  |  | 4 | 1 | 2437 | my $string = shift; | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 4 |  |  |  |  | 10 | my $ascii = _generator($string); | 
| 47 | 4 |  |  |  |  | 6 | return join '', @{$ascii}; | 
|  | 4 |  |  |  |  | 16 |  | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | 1; | 
| 51 |  |  |  |  |  |  | __END__ |