Class: Arrolio::Content::Note
- Inherits:
-
Object
- Object
- Arrolio::Content::Note
- Defined in:
- lib/arrolio/content/note.rb
Overview
A semantic note group: optional label ("NOTE 1", "WARNING") plus one or more body Paragraphs. Distinct from a bare Paragraph because the flow builder renders it with a hanging indent and the label in a marker column (matching the XSL's fo:list-block rendering for notes/examples).
Wraps the legacy Paragraph-with-:note-style emission so flavors
see richer structure without breaking older flow builders.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#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(body:, label: '', id: nil, style_id: :note) ⇒ Note
constructor
A new instance of Note.
Constructor Details
#initialize(body:, label: '', id: nil, style_id: :note) ⇒ Note
Returns a new instance of Note.
16 17 18 19 20 21 22 |
# File 'lib/arrolio/content/note.rb', line 16 def initialize(body:, label: '', id: nil, style_id: :note) @label = label.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.
14 15 16 |
# File 'lib/arrolio/content/note.rb', line 14 def body @body end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/arrolio/content/note.rb', line 14 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
14 15 16 |
# File 'lib/arrolio/content/note.rb', line 14 def label @label end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
14 15 16 |
# File 'lib/arrolio/content/note.rb', line 14 def style_id @style_id end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
34 35 36 37 38 39 40 |
# File 'lib/arrolio/content/note.rb', line 34 def ==(other) other.is_a?(self.class) && label == other.label && body == other.body && id == other.id && style_id == other.style_id end |
#body_text ⇒ Object
24 25 26 27 28 |
# File 'lib/arrolio/content/note.rb', line 24 def body_text @body.map do |node| node.is_a?(Paragraph) ? node.text : node.to_s end.join(' ') end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/arrolio/content/note.rb', line 30 def empty? @body.empty? || @body.all? { |node| node.is_a?(Paragraph) && node.empty? } end |
#hash ⇒ Object
43 44 45 |
# File 'lib/arrolio/content/note.rb', line 43 def hash [self.class, label, body, id, style_id].hash end |