Module: Kreuzberg::NodeContent
- Extended by:
- T::Helpers, T::Sig
- Included in:
- NodeContentAdmonition, NodeContentCitation, NodeContentCode, NodeContentDefinitionItem, NodeContentDefinitionList, NodeContentFootnote, NodeContentFormula, NodeContentGroup, NodeContentHeading, NodeContentImage, NodeContentList, NodeContentListItem, NodeContentMetadataBlock, NodeContentPageBreak, NodeContentParagraph, NodeContentQuote, NodeContentRawBlock, NodeContentSlide, NodeContentTable, NodeContentTitle
- Defined in:
- lib/kreuzberg/native.rb
Overview
Tagged enum for node content. Each variant carries only type-specific data.
Uses ‘#[serde(tag = “node_type”)]` to avoid “type” keyword collision in Go/Java/TypeScript bindings.
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/kreuzberg/native.rb', line 270 def self.from_hash(hash) discriminator = hash[:node_type] || hash["node_type"] case discriminator when "title" then NodeContentTitle.from_hash(hash) when "heading" then NodeContentHeading.from_hash(hash) when "paragraph" then NodeContentParagraph.from_hash(hash) when "list" then NodeContentList.from_hash(hash) when "list_item" then NodeContentListItem.from_hash(hash) when "table" then NodeContentTable.from_hash(hash) when "image" then NodeContentImage.from_hash(hash) when "code" then NodeContentCode.from_hash(hash) when "quote" then NodeContentQuote.from_hash(hash) when "formula" then NodeContentFormula.from_hash(hash) when "footnote" then NodeContentFootnote.from_hash(hash) when "group" then NodeContentGroup.from_hash(hash) when "page_break" then NodeContentPageBreak.from_hash(hash) when "slide" then NodeContentSlide.from_hash(hash) when "definition_list" then NodeContentDefinitionList.from_hash(hash) when "definition_item" then NodeContentDefinitionItem.from_hash(hash) when "citation" then NodeContentCitation.from_hash(hash) when "admonition" then NodeContentAdmonition.from_hash(hash) when "raw_block" then NodeContentRawBlock.from_hash(hash) when "metadata_block" then NodeContentMetadataBlock.from_hash(hash) else raise "Unknown discriminator: #{discriminator}" end end |