module Epubber::Models::Concerns::HasChapters

Public Instance Methods

chapter() { |chapter| ... } click to toggle source

Add chapter

# File lib/epubber/models/concerns/has_chapters.rb, line 11
def chapter
  raise 'No block given' unless block_given?
  chapter = Epubber::Models::Chapter.new
  yield chapter
  chapter.id(chapters.count + 1)
  chapters << chapter
end
chapters() click to toggle source
# File lib/epubber/models/concerns/has_chapters.rb, line 6
def chapters
  @chapters ||= []
end
contextified_chapters() click to toggle source
# File lib/epubber/models/concerns/has_chapters.rb, line 19
def contextified_chapters
  chapters.map do |chapter|
    chapter.contextify
  end
end