File Coverage

blib/lib/Aozora2Epub/File.pm
Criterion Covered Total %
statement 28 31 90.3
branch 2 2 100.0
condition n/a
subroutine 9 10 90.0
pod 1 3 33.3
total 40 46 86.9


line stmt bran cond sub pod time code
1             package Aozora2Epub::File;
2 6     6   36 use strict;
  6         13  
  6         243  
3 6     6   26 use warnings;
  6         8  
  6         308  
4 6     6   45 use utf8;
  6         13  
  6         38  
5 6     6   194 use Aozora2Epub::Gensym;
  6         11  
  6         391  
6 6     6   53 use HTML::Element;
  6         9  
  6         44  
7 6     6   205 use base qw(Class::Accessor);
  6         119  
  6         317  
8             __PACKAGE__->mk_accessors(qw/content name/);
9              
10             our $VERSION = '0.05';
11              
12             sub new {
13 45     45 1 138 my ($class, $content) = @_;
14 45         233 return bless {
15             name => gensym,
16             content => $content,
17             }, $class;
18             }
19              
20             sub _to_html {
21 87     87   175 my $e = shift;
22 87 100       531 unless ($e->isa('HTML::Element')) {
23 35         166 return $e;
24             }
25 52         228 return $e->as_HTML('<>&', undef, {});
26             }
27              
28             sub as_html {
29 38     38 0 848 my $self = shift;
30 38         75 return join('', map { _to_html($_) } @{$self->{content}});
  87         9680  
  38         126  
31             }
32              
33             sub insert_content {
34 0     0 0   my ($self, @c) = @_;
35 0           unshift @{$self->{content}}, @c;
  0            
36             }
37              
38             1;
39              
40             __END__