Decorator/Node.pm

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 100% 22 / 22 CC 2 SCAR 3.4
CC
2
Cov
100%
format_as
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Decorator.pm ↑ Summary Decorator/Group.pm »
1 package Text::Decorator::Node;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Text::Decorator::Node - A blob of text in a Text::Decorator decoration
9  
10 =head1 SYNOPSIS
11  
12 my $node = Text::Decorator::Node->new($text);
13 $node->format_as("html");
14  
15 =head1 DESCRIPTION
16  
17 This represents a piece of text which is going to undergo formatting
18 and decoration.
19  
20 =head1 METHODS
21  
22 =head2 new
23  
24 my $node = Text::Decorator::Node->new($text);
25  
26 Creates a new Text::Decorator::Node instance with the specified text.
27  
28 =cut
29  
30 13 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
31 13 my ($class, $text) = @_;
32 13 return bless {
33 representations => { text => $text },
34 notes => {} # So filters can pass messages to each other
35 } => $class;
36 }
37  
38 =head2 format_as
39  
40 $node->format_as($representation)
41  
42 Returns this node in the specified representation, or plain text.
43  
44 =cut
45  
46 22 ▶sub format_as {
Subroutine format_as: called CC=2 SCAR=6.9
Pod documented
47 22 my ($self, $format) = @_;
48 return $self->{representations}{$format}
49 22 ▶ || $self->{representations}{text};
Condition100%3/3
$self->{'representations'}{$format} || $self->{'representations'}{'text'}
l!l&&r!l&&!r
1453
MC/DC100%2/2
$self->{'representations'}{$format} || $self->{'representations'}{'text'}
$self->{'representations'}{$format} $self->{'representations'}{'text'}
Truth table100%3/3
A || B
A= $self->{'representations'}{$format}B= $self->{'representations'}{'text'}
ABresult
1X1
011
000
50 }
51  
52 7 1;
53  
« Decorator.pm ↑ Summary Decorator/Group.pm »