Class: Kramdown::PlantUml::SvgDiagram
- Defined in:
- lib/kramdown-plantuml/svg_diagram.rb
Overview
A diagram in SVG format.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(plantuml_result) ⇒ SvgDiagram
constructor
A new instance of SvgDiagram.
- #style ⇒ Object
- #to_s ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(plantuml_result) ⇒ SvgDiagram
Returns a new instance of SvgDiagram.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kramdown-plantuml/svg_diagram.rb', line 12 def initialize(plantuml_result) raise ArgumentError, 'plantuml_result cannot be nil' if plantuml_result.nil? raise ArgumentError, "plantuml_result must be a #{PlantUmlResult}" unless plantuml_result.is_a?(PlantUmlResult) plantuml_result.validate! svg = plantuml_result.stdout @doc = REXML::Document.new svg @source = plantuml_result.plantuml_diagram @style_builder = StyleBuilder.new (plantuml_result) end |
Instance Method Details
#height ⇒ Object
42 43 44 |
# File 'lib/kramdown-plantuml/svg_diagram.rb', line 42 def height get_xml_attribute_value(:height) end |
#style ⇒ Object
46 47 48 |
# File 'lib/kramdown-plantuml/svg_diagram.rb', line 46 def style get_xml_attribute_value(:style) end |
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kramdown-plantuml/svg_diagram.rb', line 24 def to_s return '' if @doc.root.nil? wrapper_doc = REXML::Document.new wrapper_doc.context[:attribute_quote] = :quote wrapper_element = REXML::Element.new('div').tap do |div| div.add_attribute 'class', wrapper_class_name div.add_element @doc.root end wrapper_doc.add_element wrapper_element wrapper_doc.to_s end |
#width ⇒ Object
38 39 40 |
# File 'lib/kramdown-plantuml/svg_diagram.rb', line 38 def width get_xml_attribute_value(:width) end |