Class: Arrolio::Content::Heading
- Inherits:
-
Object
- Object
- Arrolio::Content::Heading
- Defined in:
- lib/arrolio/content/heading.rb
Overview
A semantic heading. Distinct from Paragraph so the renderer
can emit PDF structure tags (for accessibility/ToC), the engine
can record heading → page mappings for cross-references, and the
FlowBuilder can apply distinct rendering rules (keep_together,
page-break-before, outline level).
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(level:, title:, number: nil, id: nil, style_id: :heading_1) ⇒ Heading
constructor
A new instance of Heading.
- #inline_header? ⇒ Boolean
Constructor Details
#initialize(level:, title:, number: nil, id: nil, style_id: :heading_1) ⇒ Heading
Returns a new instance of Heading.
13 14 15 16 17 18 19 20 |
# File 'lib/arrolio/content/heading.rb', line 13 def initialize(level:, title:, number: nil, id: nil, style_id: :heading_1) @level = level.to_i @number = number&.to_s @title = title.to_s @id = id&.to_s @style_id = style_id.to_sym freeze end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/arrolio/content/heading.rb', line 11 def id @id end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
11 12 13 |
# File 'lib/arrolio/content/heading.rb', line 11 def level @level end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
11 12 13 |
# File 'lib/arrolio/content/heading.rb', line 11 def number @number end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
11 12 13 |
# File 'lib/arrolio/content/heading.rb', line 11 def style_id @style_id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/arrolio/content/heading.rb', line 11 def title @title end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
22 23 24 25 26 27 28 29 |
# File 'lib/arrolio/content/heading.rb', line 22 def ==(other) other.is_a?(self.class) && level == other.level && number == other.number && title == other.title && id == other.id && style_id == other.style_id end |
#hash ⇒ Object
33 34 35 |
# File 'lib/arrolio/content/heading.rb', line 33 def hash [self.class, level, number, title, id, style_id].hash end |
#inline_header? ⇒ Boolean
37 38 39 |
# File 'lib/arrolio/content/heading.rb', line 37 def inline_header? !number.nil? && title.empty? end |