Class: Coradoc::CoreModel::Block
- 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.
Direct Known Subclasses
AnnotationBlock, CommentBlock, ExampleBlock, HorizontalRuleBlock, ListingBlock, LiteralBlock, OpenBlock, ParagraphBlock, PassBlock, QuoteBlock, SidebarBlock, SourceBlock, VerseBlock
Instance Attribute Summary collapse
-
#block_semantic_type ⇒ String?
Semantic type for generic Block instances.
-
#content ⇒ String?
The block’s text content (simple string) For mixed content with inline elements, use children instead.
-
#delimiter_type ⇒ String?
Raw delimiter for round-trip fidelity.
-
#language ⇒ String?
Language identifier for source code blocks.
-
#lines ⇒ Array<String>?
Individual lines of content.
Attributes inherited from Base
#element_attributes, #id, #metadata_entries, #title
Class Method Summary collapse
Instance Method Summary collapse
-
#element_type ⇒ Object
Derived element_type string for backward compatibility.
- #resolve_semantic_type ⇒ Object
Methods included from ChildrenContent
#flat_text, included, #renderable_content
Methods inherited from Base
#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata
Instance Attribute Details
#block_semantic_type ⇒ String?
Returns semantic type for generic Block instances. Typed subclasses should not override this — use the class instead.
36 |
# File 'lib/coradoc/core_model/block.rb', line 36 attribute :block_semantic_type, :string |
#content ⇒ String?
Returns the block’s text content (simple string) For mixed content with inline elements, use children instead.
46 |
# File 'lib/coradoc/core_model/block.rb', line 46 attribute :content, :string |
#delimiter_type ⇒ String?
Returns raw delimiter for round-trip fidelity. Format-specific; CoreModel does NOT derive semantics from this.
41 |
# File 'lib/coradoc/core_model/block.rb', line 41 attribute :delimiter_type, :string |
#language ⇒ String?
Returns language identifier for source code blocks.
54 |
# File 'lib/coradoc/core_model/block.rb', line 54 attribute :language, :string |
#lines ⇒ Array<String>?
Returns individual lines of content.
50 |
# File 'lib/coradoc/core_model/block.rb', line 50 attribute :lines, :string, collection: true |
Class Method Details
.semantic_type ⇒ Object
17 18 19 |
# File 'lib/coradoc/core_model/block.rb', line 17 def semantic_type nil end |
Instance Method Details
#element_type ⇒ Object
Derived element_type string for backward compatibility. Returns the semantic type as a string, derived from the class or block_semantic_type.
29 30 31 |
# File 'lib/coradoc/core_model/block.rb', line 29 def element_type resolve_semantic_type&.to_s end |
#resolve_semantic_type ⇒ Object
22 23 24 |
# File 'lib/coradoc/core_model/block.rb', line 22 def resolve_semantic_type self.class.semantic_type || block_semantic_type&.to_sym end |