Class: Polites::Block
Overview
Defined Under Namespace
Classes: Blockquote, CodeBlock, Divider, Heading, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, List, OrderedList, Paragraph, UnorderedList
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
-
.build(children = [], kind: 'paragraph', level: 0, syntax: nil) ⇒ Span
Build the proper kind of span from the given arguments.
Methods inherited from Node
Constructor Details
This class inherits a constructor from Polites::Node
Class Method Details
.build(children = [], kind: 'paragraph', level: 0, syntax: nil) ⇒ Span
Build the proper kind of span from the given arguments.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/polites/block.rb', line 21 def self.build(children = [], kind: 'paragraph', level: 0, syntax: nil) case kind when 'heading1' Heading1.new(children) when 'heading2' Heading2.new(children) when 'heading3' Heading3.new(children) when 'heading4' Heading4.new(children) when 'heading5' Heading5.new(children) when 'heading6' Heading6.new(children) when 'paragraph' Paragraph.new(children) when 'unorderedList' UnorderedList.new(children, level) when 'orderedList' OrderedList.new(children, level) when 'blockquote' Blockquote.new(children) when 'divider' Divider.new(children) when 'codeblock' CodeBlock.new(children, syntax) else raise ParseError, "unknown block type #{kind.inspect}" end end |