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 (= Title, == Title, === Title, etc.)
-
Headers
-
Document divisions
-
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
-
#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
#children ⇒ Array<Base>?
Returns child elements (sections, blocks, etc.).
55 |
# File 'lib/coradoc/core_model/structural_element.rb', line 55 attribute :children, Base, collection: true |
#content ⇒ String?
Returns text content of the element.
51 |
# File 'lib/coradoc/core_model/structural_element.rb', line 51 attribute :content, :string |
#element_type ⇒ String?
Returns type of structural element (e.g., ‘section’, ‘header’, ‘preamble’, ‘division’).
43 |
# File 'lib/coradoc/core_model/structural_element.rb', line 43 attribute :element_type, :string |
#level ⇒ Integer?
Returns hierarchical level (1-6 for sections).
47 |
# File 'lib/coradoc/core_model/structural_element.rb', line 47 attribute :level, :integer |
Instance Method Details
#document? ⇒ Boolean
68 69 70 |
# File 'lib/coradoc/core_model/structural_element.rb', line 68 def document? element_type == 'document' end |
#heading_level ⇒ Integer
Heading level with sensible default
60 61 62 |
# File 'lib/coradoc/core_model/structural_element.rb', line 60 def heading_level level || 1 end |
#section? ⇒ Boolean
64 65 66 |
# File 'lib/coradoc/core_model/structural_element.rb', line 64 def section? element_type == 'section' end |