Class: Arrolio::Content::Footnote

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/content/footnote.rb

Overview

A footnote reference in the content tree. Carries the marker (e.g. "1", "a", "*") and the footnote body (paragraphs). The adapter emits these from elements; the FlowBuilder places the marker inline and defers the body to the page's footnote zone (rendered at the bottom of the page).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(marker:, body:, id: nil, style_id: :footnote) ⇒ Footnote

Returns a new instance of Footnote.



13
14
15
16
17
18
19
# File 'lib/arrolio/content/footnote.rb', line 13

def initialize(marker:, body:, id: nil, style_id: :footnote)
  @marker = marker.to_s
  @body = Array(body).freeze
  @id = id&.to_s
  @style_id = style_id.to_sym
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



11
12
13
# File 'lib/arrolio/content/footnote.rb', line 11

def body
  @body
end

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/arrolio/content/footnote.rb', line 11

def id
  @id
end

#markerObject (readonly)

Returns the value of attribute marker.



11
12
13
# File 'lib/arrolio/content/footnote.rb', line 11

def marker
  @marker
end

#style_idObject (readonly)

Returns the value of attribute style_id.



11
12
13
# File 'lib/arrolio/content/footnote.rb', line 11

def style_id
  @style_id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



31
32
33
34
35
36
37
# File 'lib/arrolio/content/footnote.rb', line 31

def ==(other)
  other.is_a?(self.class) &&
    marker == other.marker &&
    body == other.body &&
    id == other.id &&
    style_id == other.style_id
end

#body_textObject



21
22
23
24
25
# File 'lib/arrolio/content/footnote.rb', line 21

def body_text
  @body.map do |node|
    node.is_a?(Paragraph) ? node.text : node.to_s
  end.join(' ')
end

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/arrolio/content/footnote.rb', line 27

def empty?
  @marker.empty? && @body.empty?
end

#hashObject



41
42
43
# File 'lib/arrolio/content/footnote.rb', line 41

def hash
  [self.class, marker, body, id, style_id].hash
end