File Coverage

lib/Book/Bilingual/Chapter.pm
Criterion Covered Total %
statement 17 17 100.0
branch 6 8 75.0
condition n/a
subroutine 6 6 100.0
pod 1 4 25.0
total 30 35 85.7


line stmt bran cond sub pod time code
1             package Book::Bilingual::Chapter;
2             # ABSTRACT: A book chapter class
3 4     4   1009 use Mojo::Base -base;
  4         7  
  4         23  
4 4     4   536 use Carp;
  4         8  
  4         1008  
5              
6             has 'number';
7             has 'title';
8             has 'body';
9              
10 50     50 1 2547 sub new { $_[0]->SUPER::new({ body => [] }) }
11             sub num_paragraphs {
12 1     1 0 14 my ($self) = @_;
13              
14 1         2 return scalar @{$self->{body}};
  1         3  
15             }
16             sub dlineset_at { ## ($i) :> Dlineset
17 18     18 0 58 my ($self,$i) = @_;
18 18 100       35 return $self->number if $i == 0;
19 14 100       27 return $self->title if $i == 1;
20 10         17 return $self->body->[$i-2];
21             }
22             sub dlineset_count {
23 9     9 0 43 my ($self) = @_;
24              
25             return (defined $self->number ? 1 : 0)
26             + (defined $self->title ? 1 : 0)
27 9 50       19 + scalar @{$self->{body}};
  9 50       86  
28             }
29              
30             1;