File Coverage

blib/lib/EBook/EPUB/Guide/Reference.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             # Copyright (c) 2009, 2010 Oleksandr Tymoshenko <gonzo@bluezbox.com>
2             # All rights reserved.
3              
4             # Redistribution and use in source and binary forms, with or without
5             # modification, are permitted provided that the following conditions
6             # are met:
7             # 1. Redistributions of source code must retain the above copyright
8             # notice, this list of conditions and the following disclaimer.
9             # 2. Redistributions in binary form must reproduce the above copyright
10             # notice, this list of conditions and the following disclaimer in the
11             # documentation and/or other materials provided with the distribution.
12              
13             # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14             # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15             # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16             # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17             # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18             # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19             # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20             # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21             # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22             # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23             # SUCH DAMAGE.
24             package EBook::EPUB::Guide::Reference;
25 1     1   2236 use Moose;
  0            
  0            
26              
27             has [qw/href type/] => (isa => 'Str', is => 'rw');
28             has title => (
29             isa => 'Str',
30             is => 'rw',
31             predicate => 'has_title',
32             );
33              
34             sub encode
35             {
36             # $writer is instance of XML::Writer
37             my ($self, $writer) = @_;
38             my @attributes = (
39             href => $self->href(),
40             type => $self->type(),
41             );
42              
43             if ($self->has_title()) {
44             push @attributes, 'title', $self->title();
45             }
46              
47             $writer->emptyTag('reference', @attributes);
48             }
49              
50             no Moose;
51             __PACKAGE__->meta->make_immutable;
52              
53             1;
54              
55             __END__
56              
57             =head1 NAME
58              
59             EBook::EPUB::Guide::Reference
60              
61             =head1 SYNOPSIS
62              
63             Reference for E<lt>guideE<gt> element of OPF file.
64              
65             =head1 SUBROUTINES/METHODS
66              
67             =over 4
68              
69             =item new(%opts)
70              
71             %opts is an anonymous hash that might containe followig keys:
72              
73             type
74             href
75             title
76              
77             =item encode($xmlwriter)
78              
79             Encode object to XML form using XML::Writer instance
80              
81             =item href([$href])
82              
83             Get/set reference to an OPS Content Document included in the
84             manifest, and which may include a fragment identifier as defined
85             in section 4.1 of RFC 2396
86              
87             =item title([$title])
88              
89             Human-readable description of reference
90              
91             =item type([$type])
92              
93             Get/set type of reference. Possible values:
94              
95             =over 4
96              
97             =item cover
98              
99             =item title-page
100              
101             =item toc
102              
103             =item index
104              
105             =item glossary
106              
107             =item acknowledgements
108              
109             =item bibliography
110              
111             =item colophon
112              
113             =item copyright-page
114              
115             =item dedication
116              
117             =item epigraph
118              
119             =item foreword
120              
121             =item loi
122              
123             =item lot
124              
125             =item notes
126              
127             =item preface
128              
129             =item text
130              
131             =back
132              
133             For detailed description refer to section 2.6 of OPF specification or
134             Chicago Manual of Style
135              
136             =back
137              
138             =head1 AUTHOR
139              
140             Oleksandr Tymoshenko, E<lt>gonzo@bluezbox.comE<gt>
141              
142             =head1 BUGS
143              
144             Please report any bugs or feature requests to E<lt>gonzo@bluezbox.comE<gt>
145              
146             =head1 LICENSE AND COPYRIGHT
147              
148             Copyright 2009, 2010 Oleksandr Tymoshenko.
149              
150             L<http://bluezbox.com>
151              
152             This module is free software; you can redistribute it and/or
153             modify it under the terms of the BSD license. See the F<LICENSE> file
154             included with this distribution.