Class: Lutaml::Xsd::Spa::Svg::DocumentBuilder
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Spa::Svg::DocumentBuilder
- Defined in:
- lib/lutaml/xsd/spa/svg/document_builder.rb
Overview
Assembles final SVG document from components
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #build(components, dimensions) ⇒ Object
-
#initialize(config) ⇒ DocumentBuilder
constructor
A new instance of DocumentBuilder.
Constructor Details
#initialize(config) ⇒ DocumentBuilder
Returns a new instance of DocumentBuilder.
13 14 15 16 |
# File 'lib/lutaml/xsd/spa/svg/document_builder.rb', line 13 def initialize(config) @config = config @defs_builder = DefsBuilder.new(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/lutaml/xsd/spa/svg/document_builder.rb', line 11 def config @config end |
Instance Method Details
#build(components, dimensions) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lutaml/xsd/spa/svg/document_builder.rb', line 18 def build(components, dimensions) width = dimensions&.width || 800 height = dimensions&.height || 600 " <svg xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n width=\"\#{width}\" height=\"\#{height}\"\n viewBox=\"0 0 \#{width} \#{height}\">\n \#{@defs_builder.build}\n \#{build_styles}\n <g id=\"diagram-content\">\n \#{components.join(\"\\n\")}\n </g>\n </svg>\n SVG\nend\n" |