| 1 | package Text::Annotated::Line; | ||||||||||||||||||||
| 2 | # $Id: Line.pm,v 1.6 2007-05-12 18:39:16 wim Exp $ | ||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use fields qw(filename linenr content); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use overload ( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | "\"\"" => \&stringify | |||||||||||||||||||
| 8 | 2 | ); | |||||||||||||||||||
| 9 | 2 | $VERSION = '0.04'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||
| 12 | 2 | my $proto = shift; | |||||||||||||||||||
| 13 | 2 | ▶ | my $pkg = ref($proto) || $proto; | ||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | # build the object | ||||||||||||||||||||
| 16 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 2 | my $this = bless [\%{"${pkg}::FIELDS"}], $pkg; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | # initialize any specified fields | ||||||||||||||||||||
| 20 | 2 | my %arg = @_; | |||||||||||||||||||
| 21 | 2 | ▶ | while(my($k,$v) = each %arg) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 2 | $this->{$k} = $v; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | return $this; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub clone { # returns a deep copy | ||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 29 | 0 | my $this = shift; | |||||||||||||||||||
| 30 | return $this->new( | ||||||||||||||||||||
| 31 | filename => $this->{filename}, | ||||||||||||||||||||
| 32 | linenr => $this->{linenr}, | ||||||||||||||||||||
| 33 | content => $this->{content}, | ||||||||||||||||||||
| 34 | 0 | ); | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub stringify { | ||||||||||||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 38 | 0 | my Text::Annotated::Line $this = shift; | |||||||||||||||||||
| 39 | 0 | $this->{content}; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub stringify_annotated { | ||||||||||||||||||
|
Subroutine
stringify_annotated: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 43 | 0 | my Text::Annotated::Line $this = shift; | |||||||||||||||||||
| 44 | 0 | my $file = $this->{filename}; | |||||||||||||||||||
| 45 | 0 | my $linenr = sprintf('%05d',$this->{linenr}); | |||||||||||||||||||
| 46 | 0 | my $content = $this->{content}; | |||||||||||||||||||
| 47 | 0 | chomp $content; | |||||||||||||||||||
| 48 | 0 | return "[$file\#$linenr]$content"; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 2 | 1; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||