Sha256: 264df9a974e3b5e3b9ff12cb9f92a3e3775dd97d9287202f427cabb3118e8224

Contents?: true

Size: 474 Bytes

Versions: 6

Compression:

Stored size: 474 Bytes

Contents

require 'epubber/models/chapter'

module Epubber::Models::Concerns
  module HasChapters
    def chapters
      @chapters ||= []
    end

    # Add chapter
    def chapter
      raise 'No block given' unless block_given?
      chapter = Epubber::Models::Chapter.new
      yield chapter
      chapter.id(chapters.count + 1)
      chapters << chapter
    end

    def contextified_chapters
      chapters.map do |chapter|
        chapter.contextify
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
epubber-0.1.5 lib/epubber/models/concerns/has_chapters.rb
epubber-0.1.4 lib/epubber/models/concerns/has_chapters.rb
epubber-0.1.3 lib/epubber/models/concerns/has_chapters.rb
epubber-0.1.2 lib/epubber/models/concerns/has_chapters.rb
epubber-0.1.1 lib/epubber/models/concerns/has_chapters.rb
epubber-0.1.0 lib/epubber/models/concerns/has_chapters.rb