Class: Kramdown::PlantUml::PlantUmlDiagram
- Defined in:
- lib/kramdown-plantuml/plantuml_diagram.rb
Overview
Represents a PlantUML diagram that can be converted to SVG.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#plantuml ⇒ Object
readonly
Returns the value of attribute plantuml.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(plantuml, options) ⇒ PlantUmlDiagram
constructor
A new instance of PlantUmlDiagram.
- #svg ⇒ Object
Constructor Details
#initialize(plantuml, options) ⇒ PlantUmlDiagram
Returns a new instance of PlantUmlDiagram.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kramdown-plantuml/plantuml_diagram.rb', line 17 def initialize(plantuml, ) raise ArgumentError, 'options cannot be nil' if .nil? raise ArgumentError, "options must be a '#{Options}'." unless .is_a?(Options) @plantuml = plantuml.strip unless plantuml.nil? @options = @theme = Theme.new() @logger = LogWrapper.init @executor = Executor.new @logger.warn 'PlantUML diagram is empty' if @plantuml.nil? || @plantuml.empty? end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/kramdown-plantuml/plantuml_diagram.rb', line 15 def @options end |
#plantuml ⇒ Object (readonly)
Returns the value of attribute plantuml.
15 16 17 |
# File 'lib/kramdown-plantuml/plantuml_diagram.rb', line 15 def plantuml @plantuml end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
15 16 17 |
# File 'lib/kramdown-plantuml/plantuml_diagram.rb', line 15 def result @result end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
15 16 17 |
# File 'lib/kramdown-plantuml/plantuml_diagram.rb', line 15 def theme @theme end |
Instance Method Details
#svg ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kramdown-plantuml/plantuml_diagram.rb', line 29 def svg return @svg_diagram unless @svg_diagram.nil? @plantuml = @theme.apply(@plantuml) log(@plantuml) @result = @executor.execute(self) @svg_diagram = SvgDiagram.new(@result) rescue StandardError => e raise e if @options.raise_errors? @logger.error e.to_s end |