Class: Coradoc::CoreModel::Block

Inherits:
Base
  • Object
show all
Includes:
ChildrenContent
Defined in:
lib/coradoc/core_model/block.rb

Overview

Generic block model

Represents all block-level elements in a format-neutral way. Typed subclasses (SourceBlock, QuoteBlock, etc.) express their semantic identity via the class hierarchy — the class IS the type. Generic Block instances use block_semantic_type for typing.

Instance Attribute Summary collapse

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ChildrenContent

#children=, #flat_text, included, #initialize, #renderable_content, #to_hash

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Attribute Details

#block_semantic_typeString?

Returns semantic type for generic Block instances. Typed subclasses should not override this — use the class instead.

Returns:

  • (String, nil)

    semantic type for generic Block instances. Typed subclasses should not override this — use the class instead.



53
# File 'lib/coradoc/core_model/block.rb', line 53

attribute :block_semantic_type, :string

#contentString?

Returns the block’s text content (simple string) For mixed content with inline elements, use children instead.

Returns:

  • (String, nil)

    the block’s text content (simple string) For mixed content with inline elements, use children instead.



68
# File 'lib/coradoc/core_model/block.rb', line 68

attribute :content, :string

#delimiter_typeString?

Returns raw delimiter for round-trip fidelity. Format-specific; CoreModel does NOT derive semantics from this.

Returns:

  • (String, nil)

    raw delimiter for round-trip fidelity. Format-specific; CoreModel does NOT derive semantics from this.



58
# File 'lib/coradoc/core_model/block.rb', line 58

attribute :delimiter_type, :string

#element_typeString?

Returns format-specific structural role. Not used for CoreModel type resolution.

Returns:

  • (String, nil)

    format-specific structural role. Not used for CoreModel type resolution.



63
# File 'lib/coradoc/core_model/block.rb', line 63

attribute :element_type, :string

#languageString?

Returns language identifier for source code blocks.

Returns:

  • (String, nil)

    language identifier for source code blocks



76
# File 'lib/coradoc/core_model/block.rb', line 76

attribute :language, :string

#linesArray<String>?

Returns individual lines of content.

Returns:

  • (Array<String>, nil)

    individual lines of content



72
# File 'lib/coradoc/core_model/block.rb', line 72

attribute :lines, :string, collection: true

Class Method Details

.semantic_typeObject



41
42
43
# File 'lib/coradoc/core_model/block.rb', line 41

def semantic_type
  nil
end

Instance Method Details

#resolve_semantic_typeObject



46
47
48
# File 'lib/coradoc/core_model/block.rb', line 46

def resolve_semantic_type
  self.class.semantic_type || block_semantic_type&.to_sym
end