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
#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_type ⇒ String?
Returns semantic type for generic Block instances. Typed subclasses should not override this — use the class instead.
34 |
# File 'lib/coradoc/core_model/block.rb', line 34 attribute :block_semantic_type, :string |
#content ⇒ String?
Returns the block’s text content (simple string) For mixed content with inline elements, use children instead.
44 |
# File 'lib/coradoc/core_model/block.rb', line 44 attribute :content, :string |
#delimiter_type ⇒ String?
Returns raw delimiter for round-trip fidelity. Format-specific; CoreModel does NOT derive semantics from this.
39 |
# File 'lib/coradoc/core_model/block.rb', line 39 attribute :delimiter_type, :string |
#language ⇒ String?
Returns language identifier for source code blocks.
52 |
# File 'lib/coradoc/core_model/block.rb', line 52 attribute :language, :string |
#lines ⇒ Array<String>?
Returns individual lines of content.
48 |
# File 'lib/coradoc/core_model/block.rb', line 48 attribute :lines, :string, collection: true |
Class Method Details
.semantic_type ⇒ Object
15 16 17 |
# File 'lib/coradoc/core_model/block.rb', line 15 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.
27 28 29 |
# File 'lib/coradoc/core_model/block.rb', line 27 def element_type resolve_semantic_type&.to_s end |
#resolve_semantic_type ⇒ Object
20 21 22 |
# File 'lib/coradoc/core_model/block.rb', line 20 def resolve_semantic_type self.class.semantic_type || block_semantic_type&.to_sym end |