Class: Markbridge::AST::Node Abstract
- Inherits:
-
Object
- Object
- Markbridge::AST::Node
- Defined in:
- lib/markbridge/ast/node.rb
Overview
Subclass and add specific behavior
Base class for all AST nodes. This is a marker class that serves as the common ancestor for all AST nodes.
The AST hierarchy consists of:
All node types inherit from this base class to enable type checking and polymorphic operations on the AST tree.
Direct Known Subclasses
Attachment, Element, Event, HorizontalRule, LineBreak, MarkdownText, Mention, Poll, Text, Upload
Constant Summary collapse
- DESCENDANTS =
Registry of every class that inherits from Markbridge::AST::Node, direct or not. This is boot-time state: the built-in classes land here while the gem's requires run, and a consumer subclass is appended when its class body runs. Anything built from this list at freeze time (see
TagLibrary#freezeandRuleSet#freeze) covers only the classes defined up to that point; later classes go through the lazy ancestry lookups instead. []
Class Method Summary collapse
-
.ast_chain ⇒ Array<Class>
The class chain from this class up to Node, most specific class first.
-
.descendants ⇒ Array<Class>
Every known descendant class, in definition order (see DESCENDANTS — boot-time state).
-
.inherited(subclass) ⇒ Object
No
superon purpose:Class#inheritedis a no-op, so calling it adds nothing observable (verified by mutation testing).
Class Method Details
.ast_chain ⇒ Array<Class>
The class chain from this class up to Markbridge::AST::Node, most specific class first. Cached on the class: the chain is pure class structure and can never change once the class is defined, so one array per class serves the whole process. The normalizer and the tag library use it for ancestry matching.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/markbridge/ast/node.rb', line 46 def self.ast_chain @ast_chain ||= begin chain = [self] sup = superclass while sup <= Node chain << sup sup = sup.superclass end chain.freeze end end |
.descendants ⇒ Array<Class>
Returns every known descendant class, in definition order (see DESCENDANTS — boot-time state).
35 36 37 |
# File 'lib/markbridge/ast/node.rb', line 35 def self.descendants DESCENDANTS end |
.inherited(subclass) ⇒ Object
No super on purpose: Class#inherited is a no-op, so calling
it adds nothing observable (verified by mutation testing).
29 30 31 |
# File 'lib/markbridge/ast/node.rb', line 29 def self.inherited(subclass) DESCENDANTS << subclass end |