Class: Coradoc::CoreModel::InlineElement
- Includes:
- ChildrenContent
- Defined in:
- lib/coradoc/core_model/inline_element.rb
Overview
Generic inline formatting element
Typed subclasses (BoldElement, ItalicElement, etc.) express their format identity via the class hierarchy — the class IS the format type. Generic InlineElement instances use the format_type attribute for typing.
Direct Known Subclasses
BoldElement, CrossReferenceElement, FootnoteElement, HardLineBreakElement, HighlightElement, ItalicElement, LineBreakElement, LinkElement, MonospaceElement, RawInlineElement, SpanElement, StemElement, StrikethroughElement, SubscriptElement, SuperscriptElement, TermElement, TextElement, UnderlineElement
Constant Summary collapse
- FORMAT_TYPES =
%w[ bold italic monospace underline strikethrough subscript superscript highlight link xref stem footnote hard_line_break text span term line_break quotation ].freeze
Instance Attribute Summary
Attributes inherited from Base
#element_attributes, #id, #metadata_entries, #title
Class Method Summary collapse
Instance Method Summary collapse
-
#link_kind ⇒ Object
Polymorphic classification used by LinkRewriter::Visitor.
- #resolve_format_type ⇒ Object
Methods included from ChildrenContent
#flat_text, included, #renderable_content
Methods included from HasChildren
Methods inherited from Base
#accept, #attr, #body_content?, build, #flat_text, #metadata, #semantically_equivalent?, #set_attr, #set_metadata, #whitespace_only?
Class Method Details
.format_type ⇒ Object
15 16 17 |
# File 'lib/coradoc/core_model/inline_element.rb', line 15 def self.format_type nil end |
.format_type_class(type) ⇒ Object
19 20 21 |
# File 'lib/coradoc/core_model/inline_element.rb', line 19 def self.format_type_class(type) FORMAT_TYPE_CLASS_MAP[type] || InlineElement end |
Instance Method Details
#link_kind ⇒ Object
Polymorphic classification used by LinkRewriter::Visitor. Returns :link / :xref when this node carries a rewrite-able target, nil otherwise. Generic InlineElement instances defer to their resolved format_type; typed subclasses override with a literal. Keeps the visitor free of class-keyed case/when (OCP).
32 33 34 35 36 37 |
# File 'lib/coradoc/core_model/inline_element.rb', line 32 def link_kind case resolve_format_type when 'link' then :link when 'xref' then :xref end end |
#resolve_format_type ⇒ Object
23 24 25 |
# File 'lib/coradoc/core_model/inline_element.rb', line 23 def resolve_format_type self.class.format_type || format_type end |