Class: Polites::Span
Overview
A span is an element mapping to inline formatting, such as text formatting and images. Spans only exist within blocks and cannot themselves contain Block nodes.
Defined Under Namespace
Classes: Annotation, Code, Delete, Emph, Footnote, Image, Link, Mark, Strong
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
-
.build(children = [], kind: nil, url: nil, image: nil, filename: nil, title: nil, description: nil, width: nil, height: nil, text: 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: nil, url: nil, image: nil, filename: nil, title: nil, description: nil, width: nil, height: nil, text: nil) ⇒ Span
Build the proper kind of span from the given arguments.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/polites/span.rb', line 25 def self.build(children = [], kind: nil, url: nil, image: nil, filename: nil, title: nil, description: nil, width: nil, height: nil, text: nil) case kind when 'link' Span::Link.new(children, url: url, title: title) when 'mark' Span::Mark.new(children) when 'emph' Span::Emph.new(children) when 'strong' Span::Strong.new(children) when 'annotation' Span::Annotation.new(children, text) when 'footnote' Span::Footnote.new(children, text) when 'delete' Span::Delete.new(children) when 'code' Span::Code.new(children) when 'image' Span::Image.new(children, image: image, filename: filename, title: title, description: description, width: width, height: height) else raise ParseError, "unexpected kind #{kind.inspect}" end end |