From 1c131dcd79d287911dfa3b7f6fb5fc8e7d0fa4ba Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 11 Aug 2012 17:29:09 -0400 Subject: Remove type-specific document modules. --- (limited to 'scripts/MarkdownBook/Document.pm') 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) = @_; -- cgit v0.9.1