Class: Uniword::Header
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Uniword::Header
- Defined in:
- lib/uniword/header.rb
Overview
Represents a document header Headers can contain paragraphs and tables
Constant Summary collapse
- TYPES =
Valid header types
%w[default first even].freeze
Instance Method Summary collapse
-
#elements ⇒ Object
Get all content elements (paragraphs and tables) in order.
-
#empty? ⇒ Boolean
Check if header is empty.
-
#initialize(**attributes) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(**attributes) ⇒ Header
Returns a new instance of Header.
18 19 20 21 |
# File 'lib/uniword/header.rb', line 18 def initialize(**attributes) super validate_type end |
Instance Method Details
#elements ⇒ Object
Get all content elements (paragraphs and tables) in order
24 25 26 27 28 |
# File 'lib/uniword/header.rb', line 24 def elements (paragraphs + tables).sort_by do |elem| paragraphs.index(elem) || (tables.index(elem) + paragraphs.size) end end |
#empty? ⇒ Boolean
Check if header is empty
31 32 33 |
# File 'lib/uniword/header.rb', line 31 def empty? paragraphs.empty? && tables.empty? end |