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