Class: Coradoc::CoreModel::InlineElement

Inherits:
Base
  • Object
show all
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.

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

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

Class Method Details

.format_typeObject



14
15
16
# File 'lib/coradoc/core_model/inline_element.rb', line 14

def format_type
  nil
end

.format_type_class(type) ⇒ Object



18
19
20
# File 'lib/coradoc/core_model/inline_element.rb', line 18

def format_type_class(type)
  FORMAT_TYPE_CLASS_MAP[type] || InlineElement
end

Instance Method Details

#resolve_format_typeObject



23
24
25
# File 'lib/coradoc/core_model/inline_element.rb', line 23

def resolve_format_type
  self.class.format_type || format_type
end