Class: Ea::Svg::EaEmitter::Document
- Inherits:
-
Object
- Object
- Ea::Svg::EaEmitter::Document
- Defined in:
- lib/ea/svg/ea_emitter/document.rb
Overview
Top-level orchestrator: emits a complete standalone SVG document matching EA's encoding. Bound computation and layer sequencing delegated to BoundsCalculator and LayerSequencer respectively (SRP).
Constant Summary collapse
- BUILD_ID =
"1624"
Instance Attribute Summary collapse
-
#diagram ⇒ Object
readonly
Returns the value of attribute diagram.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
-
#model_index ⇒ Object
readonly
Returns the value of attribute model_index.
Instance Method Summary collapse
-
#initialize(diagram, model_index:, frame: true, document: nil, **_options) ⇒ Document
constructor
A new instance of Document.
- #render ⇒ Object
Constructor Details
#initialize(diagram, model_index:, frame: true, document: nil, **_options) ⇒ Document
Returns a new instance of Document.
15 16 17 18 19 20 |
# File 'lib/ea/svg/ea_emitter/document.rb', line 15 def initialize(diagram, model_index:, frame: true, document: nil, **) @diagram = diagram @model_index = model_index @frame = frame @document = document end |
Instance Attribute Details
#diagram ⇒ Object (readonly)
Returns the value of attribute diagram.
13 14 15 |
# File 'lib/ea/svg/ea_emitter/document.rb', line 13 def diagram @diagram end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
13 14 15 |
# File 'lib/ea/svg/ea_emitter/document.rb', line 13 def document @document end |
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
13 14 15 |
# File 'lib/ea/svg/ea_emitter/document.rb', line 13 def frame @frame end |
#model_index ⇒ Object (readonly)
Returns the value of attribute model_index.
13 14 15 |
# File 'lib/ea/svg/ea_emitter/document.rb', line 13 def model_index @model_index end |
Instance Method Details
#render ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ea/svg/ea_emitter/document.rb', line 22 def render canvas = Canvas.from(diagram, model_index: model_index) layers = LayerSequencer.new(diagram, model_index: model_index, canvas: canvas, frame: frame, document: document) .layers .reject { |s| s.nil? || s.empty? } %(<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\n\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="#{canvas.width_cm}" height="#{canvas.height_cm}" viewBox="#{canvas.view_box}">\n<title></title>\n<desc>Created with Enterprise Architect (Build: #{BUILD_ID}) 2</desc>\n#{layers.join("\n")}\n</svg>) end |