File Coverage

lib/Book/Bilingual.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 9 9 100.0
pod 2 6 33.3
total 37 41 90.2


line stmt bran cond sub pod time code
1             package Book::Bilingual;
2             # ABSTRACT: Data structure for a bilingual book
3 4     4   119123 use Mojo::Base -base;
  4         332995  
  4         23  
4 4     4   649 use Carp;
  4         8  
  4         287  
5              
6 4     4   1824 use version; our $VERSION = version->declare('0.002');
  4         6353  
  4         17  
7              
8             has 'chapters'; # ArrayRef of Book::Bilingual::Chapter
9              
10 27     27 1 4474 sub new { $_[0]->SUPER::new({ chapters => [] }) }
11             sub chapter_count { ## () :> Int
12 11     11 0 46 my ($self) = @_;
13              
14 11         10 return scalar @{$self->{chapters}};
  11         23  
15             }
16             sub push { ## ($chapter:>Book::Bilingual::Chapter) :> Self
17 44     44 0 276 my ($self, $chapter) = @_;
18              
19 44 100       261 croak 'Not a Book::Bilingual::Chapter'
20             unless ref($chapter) eq 'Book::Bilingual::Chapter';
21              
22 43         41 push @{$self->{chapters}}, $chapter;
  43         78  
23              
24 43         88 return $self;
25             }
26              
27             sub chapter_at { ## ($ch_idx :>Int) :> Int
28 3     3 0 20 my ($self, $ch_idx) = @_;
29 3         15 return $self->{chapters}[$ch_idx];
30             }
31              
32             sub chapter_dlineset_count { ## ($ch_idx) :> Int
33 7     7 1 40 my ($self,$ch_idx) = @_;
34 7         14 return $self->chapters->[$ch_idx]->dlineset_count;
35             }
36             sub chapter_dlineset_dline_len { ## ($ch_idx, $dset_idx) :> Int
37 8     8 0 36 my ($self, $ch_idx, $dset_idx) = @_;
38 8         14 return $self->chapters->[$ch_idx]->dlineset_at($dset_idx)->dline_count;
39             }
40              
41             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 is a model for bilingual books written in Markdown
63             format. The L 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 Ehoekit at gmail.comE
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