| 1 | package Silki::Formatter::HTMLToWiki::Table::Cell; | ||||||||||||||
| 2 | { | ||||||||||||||
| 3 | 1 | $Silki::Formatter::HTMLToWiki::Table::Cell::VERSION = '0.29'; | |||||||||||||
| 4 | } | ||||||||||||||
| 5 | |||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use namespace::autoclean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 1 | ▶ | use Silki::Types qw( Int Str Bool ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 1 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 1 | ▶ | use MooseX::SemiAffordanceAccessor; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 1 | ▶ | use MooseX::StrictConstructor; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | 1 | has colspan => ( | |||||||||||||
| 18 | is => 'ro', | ||||||||||||||
| 19 | isa => Int, | ||||||||||||||
| 20 | default => 1, | ||||||||||||||
| 21 | ); | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 1 | has alignment => ( | |||||||||||||
| 24 | is => 'ro', | ||||||||||||||
| 25 | isa => enum( [qw( left right center )] ), | ||||||||||||||
| 26 | default => 'left', | ||||||||||||||
| 27 | ); | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 1 | has is_header_cell => ( | |||||||||||||
| 30 | is => 'ro', | ||||||||||||||
| 31 | isa => Bool, | ||||||||||||||
| 32 | default => 0, | ||||||||||||||
| 33 | ); | ||||||||||||||
| 34 | |||||||||||||||
| 35 | 1 | has content => ( | |||||||||||||
| 36 | traits => ['String'], | ||||||||||||||
| 37 | is => 'rw', | ||||||||||||||
| 38 | isa => Str, | ||||||||||||||
| 39 | default => q{}, | ||||||||||||||
| 40 | handles => { | ||||||||||||||
| 41 | append_content => 'append', | ||||||||||||||
| 42 | }, | ||||||||||||||
| 43 | init_arg => undef, | ||||||||||||||
| 44 | ); | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 38 | ▶ | sub formatted_content { | ||||||||||||
|
Subroutine
formatted_content: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||
| 47 | 38 | my $self = shift; | |||||||||||||
| 48 | 38 | my $width = shift; | |||||||||||||
| 49 | |||||||||||||||
| 50 | 38 | $width += 4 * ( $self->colspan() - 1 ); | |||||||||||||
| 51 | |||||||||||||||
| 52 | 38 | ▶ | my $format | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 53 | = $self->alignment() eq 'left' ? " %-${width}s " | ||||||||||||||
| 54 | : $self->alignment() eq 'right' ? " %${width}s " | ||||||||||||||
| 55 | : " %-${width}s "; | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 38 | my $content = $self->content(); | |||||||||||||
| 58 | 38 | $content =~ s/\n/ /g; | |||||||||||||
| 59 | |||||||||||||||
| 60 | 38 | return sprintf( $format, $content ); | |||||||||||||
| 61 | } | ||||||||||||||
| 62 | |||||||||||||||
| 63 | 1 | __PACKAGE__->meta()->make_immutable(); | |||||||||||||
| 64 | |||||||||||||||
| 65 | 1 | 1; | |||||||||||||