Class: Uniword::Header

Inherits:
Lutaml::Model::Serializable
  • Object
show all
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

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

#elementsObject

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

Returns:

  • (Boolean)


31
32
33
# File 'lib/uniword/header.rb', line 31

def empty?
  paragraphs.empty? && tables.empty?
end