Class: Uniword::Builder::FootnoteBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/uniword/builder/footnote_builder.rb

Overview

Builds footnotes and endnotes for documents.

Manages footnote/endnote creation, ID assignment, and wiring references into the document body. Uses IdAllocator for all ID assignment when available.

Instance Method Summary collapse

Constructor Details

#initialize(document, allocator: nil) ⇒ FootnoteBuilder

Returns a new instance of FootnoteBuilder.



11
12
13
14
# File 'lib/uniword/builder/footnote_builder.rb', line 11

def initialize(document, allocator: nil)
  @document = document
  @allocator = allocator
end

Instance Method Details

#endnote(text = nil) {|ParagraphBuilder| ... } ⇒ Wordprocessingml::Run

Create an endnote and return a Run with an endnoteReference.

Parameters:

  • text (String) (defaults to: nil)

    Endnote text content

Yields:

Returns:



35
36
37
38
39
40
41
42
# File 'lib/uniword/builder/footnote_builder.rb', line 35

def endnote(text = nil, &)
  id = next_endnote_id
  run = Wordprocessingml::Run.new(
    endnote_reference: Wordprocessingml::EndnoteReference.new(id: id.to_s)
  )
  create_endnote_entry(id, text, &)
  run
end

#footnote(text = nil) {|ParagraphBuilder| ... } ⇒ Wordprocessingml::Run

Create a footnote and return a Run with a footnoteReference.

Parameters:

  • text (String) (defaults to: nil)

    Footnote text content

Yields:

Returns:



21
22
23
24
25
26
27
28
# File 'lib/uniword/builder/footnote_builder.rb', line 21

def footnote(text = nil, &)
  id = next_footnote_id
  run = Wordprocessingml::Run.new(
    footnote_reference: Wordprocessingml::FootnoteReference.new(id: id.to_s)
  )
  create_footnote_entry(id, text, &)
  run
end