Class: Arrolio::Content::Footnote
- Inherits:
-
Object
- Object
- Arrolio::Content::Footnote
- 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
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#marker ⇒ Object
readonly
Returns the value of attribute marker.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #body_text ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(marker:, body:, id: nil, style_id: :footnote) ⇒ Footnote
constructor
A new instance of Footnote.
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/arrolio/content/footnote.rb', line 11 def body @body end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/arrolio/content/footnote.rb', line 11 def id @id end |
#marker ⇒ Object (readonly)
Returns the value of attribute marker.
11 12 13 |
# File 'lib/arrolio/content/footnote.rb', line 11 def marker @marker end |
#style_id ⇒ Object (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_text ⇒ Object
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
27 28 29 |
# File 'lib/arrolio/content/footnote.rb', line 27 def empty? @marker.empty? && @body.empty? end |
#hash ⇒ Object
41 42 43 |
# File 'lib/arrolio/content/footnote.rb', line 41 def hash [self.class, marker, body, id, style_id].hash end |