summaryrefslogtreecommitdiffstats
path: root/scripts/MarkdownBook/Document.pm
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/MarkdownBook/Document.pm')
-rw-r--r--scripts/MarkdownBook/Document.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/MarkdownBook/Document.pm b/scripts/MarkdownBook/Document.pm
index fe6634f..30c6314 100644
--- a/scripts/MarkdownBook/Document.pm
+++ b/scripts/MarkdownBook/Document.pm
@@ -23,7 +23,7 @@ package MarkdownBook::Document;
sub new
{
- my ($class, $book, $file, $id, $title) = @_;
+ my ($class, $book, $type, $file, $id, $title) = @_;
my $self;
$class = ref($class) || $class;
@@ -31,6 +31,7 @@ sub new
bless($self, $class);
$self->{'book'} = $book;
+ $self->{'type'} = $type;
$self->{'file'} = $file;
$self->{'id'} = $id;
$self->{'title'} = $title;
@@ -48,6 +49,16 @@ sub book
return $old;
}
+sub type
+{
+ my ($self, $type) = @_;
+ my $old = $self->{'type'};
+
+ $self->{'type'} = $type if defined($type);
+
+ return $old;
+}
+
sub file
{
my ($self, $file) = @_;
@@ -75,6 +86,19 @@ sub title
return $old;
}
+sub full_title
+{
+ my ($self) = @_;
+
+ if ($self->{'type'} eq 'chapter') {
+ return sprintf('Chapter %d - %s', $self->{'id'}, $self->{'title'});
+ } elsif ($self->{'type'} eq 'appendix') {
+ return sprintf('Appendix %s - %s', $self->{'id'}, $self->{'title'});
+ } else {
+ return undef;
+ }
+}
+
sub prev
{
my ($self, $other) = @_;