Class: Coradoc::CoreModel::StructuralElement
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Base
- Coradoc::CoreModel::StructuralElement
- Defined in:
- lib/coradoc/core_model/structural_element.rb
Overview
Base class for structural elements
Represents document structure elements that organize content:
-
Sections (headings at various levels)
-
Document roots
-
Preamble
Structural elements can contain other elements (blocks, lists, etc.) and can be nested hierarchically to represent document structure.
This is a base class that can be extended in future phases to handle schema-specific structural requirements.
Instance Attribute Summary collapse
-
#attributes ⇒ Metadata?
Document-level attributes (typed key-value pairs).
-
#children ⇒ Array<Base>?
Child elements (sections, blocks, etc.).
-
#content ⇒ String?
Text content of the element.
-
#element_type ⇒ String?
Type of structural element (e.g., ‘section’, ‘header’, ‘preamble’, ‘division’).
-
#level ⇒ Integer?
Hierarchical level (1-6 for sections).
Attributes inherited from Base
#element_attributes, #id, #metadata_entries, #title
Instance Method Summary collapse
- #document? ⇒ Boolean
-
#heading_level ⇒ Integer
Heading level with sensible default.
- #section? ⇒ Boolean
Methods inherited from Base
#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata
Instance Attribute Details
#attributes ⇒ Metadata?
Returns document-level attributes (typed key-value pairs).
58 |
# File 'lib/coradoc/core_model/structural_element.rb', line 58 attribute :attributes, Metadata |
#children ⇒ Array<Base>?
Returns child elements (sections, blocks, etc.).
54 |
# File 'lib/coradoc/core_model/structural_element.rb', line 54 attribute :children, Base, collection: true |
#content ⇒ String?
Returns text content of the element.
50 |
# File 'lib/coradoc/core_model/structural_element.rb', line 50 attribute :content, :string |
#element_type ⇒ String?
Returns type of structural element (e.g., ‘section’, ‘header’, ‘preamble’, ‘division’).
42 |
# File 'lib/coradoc/core_model/structural_element.rb', line 42 attribute :element_type, :string |
#level ⇒ Integer?
Returns hierarchical level (1-6 for sections).
46 |
# File 'lib/coradoc/core_model/structural_element.rb', line 46 attribute :level, :integer |
Instance Method Details
#document? ⇒ Boolean
71 72 73 |
# File 'lib/coradoc/core_model/structural_element.rb', line 71 def document? element_type == 'document' end |
#heading_level ⇒ Integer
Heading level with sensible default
63 64 65 |
# File 'lib/coradoc/core_model/structural_element.rb', line 63 def heading_level level || 1 end |
#section? ⇒ Boolean
67 68 69 |
# File 'lib/coradoc/core_model/structural_element.rb', line 67 def section? element_type == 'section' end |