Class: Coradoc::AsciiDoc::Model::Image::Core
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Base
- Coradoc::AsciiDoc::Model::Image::Core
- Includes:
- Anchorable
- Defined in:
- lib/coradoc/asciidoc/model/image/core.rb,
lib/coradoc/asciidoc/model/image/core/attribute_list.rb
Overview
Base class for image elements in AsciiDoc documents.
Images can be block-level (standalone paragraphs) or inline (within text). This base class provides common functionality for both types.
Typed promotion of attribute-list slots
Semantically meaningful image attributes (alt, role, width,
height, link) are declared as typed lutaml-model fields on
Core itself — not as validators on a generic bag. The class-level
Core.promoted_positional and Core.promoted_named methods are the single
source of truth for which slots get lifted into typed fields and in
what order; subclasses override them to reflect syntax differences
(e.g. inline images treat the 2nd positional as role, block images
do not).
The lift itself is performed by AttributeExtractor, a pure function
over (AttributeList, target_class) → (extracted_hash, residual_list).
Anything not promoted stays in attributes for round-trip fidelity.
Direct Known Subclasses
Defined Under Namespace
Classes: AttributeList
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.promoted_named ⇒ Array<Symbol>
Named attribute-list keys that this image class promotes to typed fields.
-
.promoted_positional ⇒ Array<Symbol>
Positional attribute-list slots that this image class promotes to typed fields, in order.
Instance Method Summary collapse
-
#to_adoc ⇒ String
Custom to_adoc implementation that uses ElementRegistry directly to avoid recursion issues with image serialization.
Methods included from Anchorable
#default_anchor, #gen_anchor, included, #initialize
Methods inherited from Base
#block_level?, #inline?, #serialize_content, #simplify_block_content, #to_h, visit, #visit
Class Method Details
.promoted_named ⇒ Array<Symbol>
Named attribute-list keys that this image class promotes to typed fields. The same set applies to both inline and block images.
65 66 67 |
# File 'lib/coradoc/asciidoc/model/image/core.rb', line 65 def self.promoted_named %i[width height link role] end |
.promoted_positional ⇒ Array<Symbol>
Positional attribute-list slots that this image class promotes to typed fields, in order. Subclasses override to reflect their syntax. Index 0 → alt for all image kinds; index 1 → role for inline images only.
58 59 60 |
# File 'lib/coradoc/asciidoc/model/image/core.rb', line 58 def self.promoted_positional %i[alt] end |
Instance Method Details
#to_adoc ⇒ String
Custom to_adoc implementation that uses ElementRegistry directly to avoid recursion issues with image serialization.
73 74 75 76 |
# File 'lib/coradoc/asciidoc/model/image/core.rb', line 73 def to_adoc serializer_class = Coradoc::AsciiDoc::Serializer::ElementRegistry.lookup(self.class) serializer_class.new.to_adoc(self) end |