lib/Book/Bilingual.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 33.3% 2 / 6 totaltotal 90.9% 40 / 44 CC 2 SCAR 1.8
CC
2
Cov
100%
push
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« lib/Book/Bilingual/Dlineset.pm ↑ Summary Build »
1 package Book::Bilingual;
2 # ABSTRACT: Data structure for a bilingual book
3 4 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use version; our $VERSION = version->declare('v0.001');
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 has 'chapters'; # ArrayRef of Book::Bilingual::Chapter
9  
10 27 ▶sub new { $_[0]->SUPER::new({ chapters => [] }) }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 sub chapter_count { ## () :> Int
12 11 ▶ my ($self) = @_;
Subroutine chapter_count: called CC=1 SCAR=0.0
Pod undocumented
13  
14 11 return scalar @{$self->{chapters}};
15 }
16 sub push { ## ($chapter:>Book::Bilingual::Chapter) :> Self
17 44 ▶ my ($self, $chapter) = @_;
Subroutine push: called CC=2 SCAR=6.9
Pod undocumented
18  
19 44 ▶ croak 'Not a Book::Bilingual::Chapter'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $chapter eq "Book::Bilingual::Chapter" 1 43 44
20 unless ref($chapter) eq 'Book::Bilingual::Chapter';
21  
22 43 push @{$self->{chapters}}, $chapter;
23  
24 43 return $self;
25 }
26  
27 sub chapter_at { ## ($ch_idx :>Int) :> Int
28 3 ▶ my ($self, $ch_idx) = @_;
Subroutine chapter_at: called CC=1 SCAR=0.0
Pod undocumented
29 3 return $self->{chapters}[$ch_idx];
30 }
31  
32 sub chapter_dlineset_count { ## ($ch_idx) :> Int
33 7 ▶ my ($self,$ch_idx) = @_;
Subroutine chapter_dlineset_count: called CC=1 SCAR=0.0
Pod documented
34 7 return $self->chapters->[$ch_idx]->dlineset_count;
35 }
36 sub chapter_dlineset_dline_len { ## ($ch_idx, $dset_idx) :> Int
37 8 ▶ my ($self, $ch_idx, $dset_idx) = @_;
Subroutine chapter_dlineset_dline_len: called CC=1 SCAR=0.0
Pod undocumented
38 8 return $self->chapters->[$ch_idx]->dlineset_at($dset_idx)->dline_count;
39 }
40  
41 4 1;
42  
43 =pod
44  
45 =encoding utf-8
46  
47 =head1 NAME
48  
49 Book::Bilingual - A crappy model for bilingual books
50  
51 =head1 SYNOPSIS
52  
53 use Book::Bilingual::Reader;
54  
55 my $file = 't/ff01.mdown';
56 my $reader = Book::Bilingual::Reader->new($file);
57  
58 print $reader->html();
59  
60 =head1 DESCRIPTION
61  
62 L<Book::Bilingual> is a model for bilingual books written in Markdown
63 format. The L<Book::Bilingual::Reader> module reads the file and
64 generates HTML.
65  
66 =head1 METHODS
67  
68 =head2 chapter_dlineset_count($chapter_idx:>Int) :> Int
69  
70 Returns the number of dlinesets in the given Chapter.
71  
72 =head2 num_dline_in_dlineset($chapter_idx:Int, $dlineset_idx:Int) :> Int
73  
74 Returns the number of dlines in the given Chapter and Dlineset.
75  
76 =head1 AUTHOR
77  
78 Hoe Kit CHEW E<lt>hoekit at gmail.comE<gt>
79  
80 =head1 COPYRIGHT
81  
82 Copyright (C) 2021 Hoe Kit CHEW
83  
84 =head1 LICENSE
85  
86 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
87  
88 =cut
89  
« lib/Book/Bilingual/Dlineset.pm ↑ Summary Build »