Class: Kitchen::Directions::BakeChapterReferences::V3

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_chapter_references/v3.rb

Defined Under Namespace

Classes: Reference

Instance Method Summary collapse

Instance Method Details

#bake(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.') ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/kitchen/directions/bake_chapter_references/v3.rb', line 23

def bake(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
  @references = []

  chapter.references.search('p').each do |reference_element|
    @references.push(Reference.new(reference_element.cut))
  end

  chapter.references.trash

  content = @references.sort.map { |reference| reference.element.paste }.join

  return if content.empty?

  Kitchen::Directions::CompositePageContainer.v1(
    container_key: 'references',
    uuid_key: "#{uuid_prefix}references",
    metadata_source: ,
    content: content,
    append_to: append_to || chapter
  )
end