Class: Uniword::Endnote
- Inherits:
-
Object
- Object
- Uniword::Endnote
- Defined in:
- lib/uniword/endnote.rb
Overview
Represents an endnote in a document.
Responsibility: Store endnote content and metadata. Endnotes appear at the end of the document or section, unlike footnotes which appear at the bottom of each page.
An endnote consists of:
-
An ID that uniquely identifies it
-
Content (array of paragraphs)
Instance Attribute Summary collapse
-
#content ⇒ Array<Paragraph>
The content paragraphs of the endnote.
-
#id ⇒ Integer, String
The unique identifier for this endnote.
Instance Method Summary collapse
-
#content? ⇒ Boolean
Check if endnote has content.
-
#initialize(id:, content: []) ⇒ Endnote
constructor
Initialize a new Endnote.
-
#text ⇒ String
Get text content of endnote.
-
#to_h ⇒ Hash
Convert to hash representation.
Constructor Details
#initialize(id:, content: []) ⇒ Endnote
Initialize a new Endnote.
37 38 39 40 |
# File 'lib/uniword/endnote.rb', line 37 def initialize(id:, content: []) @id = id @content = content end |
Instance Attribute Details
#content ⇒ Array<Paragraph>
Returns The content paragraphs of the endnote.
28 29 30 |
# File 'lib/uniword/endnote.rb', line 28 def content @content end |
#id ⇒ Integer, String
Returns The unique identifier for this endnote.
25 26 27 |
# File 'lib/uniword/endnote.rb', line 25 def id @id end |
Instance Method Details
#content? ⇒ Boolean
Check if endnote has content.
45 46 47 |
# File 'lib/uniword/endnote.rb', line 45 def content? !@content.nil? && !@content.empty? end |
#text ⇒ String
Get text content of endnote.
52 53 54 |
# File 'lib/uniword/endnote.rb', line 52 def text @content.map { |p| p.respond_to?(:text) ? p.text : p.to_s }.join("\n") end |
#to_h ⇒ Hash
Convert to hash representation.
59 60 61 62 63 64 |
# File 'lib/uniword/endnote.rb', line 59 def to_h { id: @id, content: @content, } end |