Module: Epubber::Models::Concerns::HasChapters
- Included in:
- Book
- Defined in:
- lib/epubber/models/concerns/has_chapters.rb
Instance Method Summary collapse
Instance Method Details
#chapter {|chapter| ... } ⇒ Object
Add chapter
11 12 13 14 15 16 17 |
# 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 ⇒ Object
6 7 8 |
# File 'lib/epubber/models/concerns/has_chapters.rb', line 6 def chapters @chapters ||= [] end |
#contextified_chapters ⇒ Object
19 20 21 22 23 |
# File 'lib/epubber/models/concerns/has_chapters.rb', line 19 def contextified_chapters chapters.map do |chapter| chapter.contextify end end |