| 1 | package Text::Snippet::TabStop; | ||||||||||
| 2 | 15 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 15 | $Text::Snippet::TabStop::VERSION = '0.04'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: Abstract class for other tab stop classes | ||||||||||
| 7 | |||||||||||
| 8 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 15 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 15 | ▶ | use overload '""' => sub { shift->to_string }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | sub parse { | ||||||||
|
Subroutine
parse: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 15 | 1 | ▶ | croak "must be implemented in sub class" if(shift eq __PACKAGE__); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 70 | ▶ | sub _new { | ||||||||
|
Subroutine
_new: called CC=4 SCAR=14.2
| |||||||||||
| 19 | 70 | my $class = shift; | |||||||||
| 20 | 70 | ▶ | croak "this is an abstract class - please instantiate a sub-class of " . __PACKAGE__ if($class eq __PACKAGE__); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | 70 | my %args = @_; | |||||||||
| 23 | 70 | for my $k(qw(src index)){ | |||||||||
| 24 | 140 | ▶ | croak "$k is required" unless defined $args{$k}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | } | ||||||||||
| 26 | 70 | return bless \%args, $class; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | use Class::XSAccessor | ||||||||||
| 31 | 15 | ▶ | getters => { src => 'src', index => 'index', replacement => 'replacement' }, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | setters => { replace => 'replacement' }, | ||||||||||
| 33 | accessors => { parent => 'parent' }, | ||||||||||
| 34 | 15 | predicates => { has_parent => 'parent', has_replacement => 'replacement' }; | |||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 133 | ▶ | sub to_string { | ||||||||
|
Subroutine
to_string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 38 | 133 | my $self = shift; | |||||||||
| 39 | 133 | ▶ | return $self->parent->to_string if($self->has_parent); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 103 | my $replacement = $self->replacement; | |||||||||
| 41 | 103 | ▶ | return defined($replacement) ? $replacement : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 15 | 1; | |||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||