Module: Sevgi::Graphics::Mixtures::Underscore
- Defined in:
- lib/sevgi/graphics/mixtures/underscore.rb
Overview
DSL helpers for floating text, comments, and inherited non-rendering context.
Instance Method Summary collapse
-
#_(*contents) ⇒ Sevgi::Graphics::Element
Creates a floating content element.
-
#Ancestral ⇒ Hash
Merges
-contextmetadata from the document root, ancestors, and this element. -
#Comment(comment) ⇒ Sevgi::Graphics::Element
Adds an XML comment.
Instance Method Details
#_(*contents) ⇒ Sevgi::Graphics::Element
Creates a floating content element.
14 15 16 |
# File 'lib/sevgi/graphics/mixtures/underscore.rb', line 14 def _(*contents) Element(:_, *contents) end |
#Ancestral ⇒ Hash
Merges -context metadata from the document root, ancestors, and this element.
Only the direct root-to-self ancestor chain participates; sibling subtrees are ignored. When the same key is
present on multiple chain elements, the nearest element to the receiver wins. Context remains available in
memory but is omitted from rendered SVG. It is unrelated to the _: XML namespace syntax preserved by
Derender.
41 42 43 44 45 46 47 48 |
# File 'lib/sevgi/graphics/mixtures/underscore.rb', line 41 def Ancestral chain = [] TraverseUp { |element| chain.unshift(element) } {}.tap do |result| chain.each { |element| result.merge!(element[CONTEXT]) if element.has?(CONTEXT) } end end |
#Comment(comment) ⇒ Sevgi::Graphics::Element
Adds an XML comment.
22 23 24 25 26 27 28 29 |
# File 'lib/sevgi/graphics/mixtures/underscore.rb', line 22 def Comment(comment) comment = XML.text(comment, context: "XML comment") ArgumentError.("XML comment must not contain '--'") if comment.include?("--") ArgumentError.("XML comment must not end with '-'") if comment.end_with?("-") _(Content.verbatim("<!-- #{comment} -->")) end |