class Kramdown::PlantUml::Diagram
Represents a PlantUML diagram that can be converted to SVG.
Attributes
plantuml[R]
result[R]
theme[R]
Public Class Methods
new(plantuml, options = {})
click to toggle source
# File lib/kramdown-plantuml/diagram.rb, line 15 def initialize(plantuml, options = {}) @plantuml = plantuml @theme = Theme.new(options || {}) @logger = Logger.init @executor = Executor.new end
Public Instance Methods
convert_to_svg()
click to toggle source
# File lib/kramdown-plantuml/diagram.rb, line 22 def convert_to_svg return @svg unless @svg.nil? if @plantuml.nil? || @plantuml.empty? @logger.warn ' kramdown-plantuml: PlantUML diagram is empty' return @plantuml end @plantuml = @theme.apply(@plantuml) @plantuml = plantuml.strip log(plantuml) @result = @executor.execute(self) @result.validate @svg = wrap(@result.without_xml_prologue) @svg end
Private Instance Methods
log(plantuml)
click to toggle source
# File lib/kramdown-plantuml/diagram.rb, line 51 def log(plantuml) @logger.debug ' kramdown-plantuml: PlantUML converting diagram:' @logger.debug_with_prefix ' kramdown-plantuml: ', plantuml end
wrap(svg)
click to toggle source
# File lib/kramdown-plantuml/diagram.rb, line 41 def wrap(svg) theme_class = @theme.name ? "theme-#{@theme.name}" : '' class_name = "plantuml #{theme_class}".strip wrapper_element_start = "<div class=\"#{class_name}\">" wrapper_element_end = '</div>' "#{wrapper_element_start}#{svg}#{wrapper_element_end}" end