Class: Lutaml::Xsd::Spa::Svg::LayoutEngine
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Spa::Svg::LayoutEngine
- Defined in:
- lib/lutaml/xsd/spa/svg/layout_engine.rb
Overview
Abstract base class for layout engines Subclasses must implement #calculate method
Direct Known Subclasses
Lutaml::Xsd::Spa::Svg::Layouts::TreeLayout, Lutaml::Xsd::Spa::Svg::Layouts::VerticalLayout
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.for(config) ⇒ Object
Factory method to create appropriate layout engine.
Instance Method Summary collapse
-
#calculate(component_data, component_type) ⇒ LayoutResult
Calculates layout for the given component data.
-
#initialize(config) ⇒ LayoutEngine
constructor
A new instance of LayoutEngine.
Constructor Details
#initialize(config) ⇒ LayoutEngine
Returns a new instance of LayoutEngine.
15 16 17 |
# File 'lib/lutaml/xsd/spa/svg/layout_engine.rb', line 15 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/lutaml/xsd/spa/svg/layout_engine.rb', line 13 def config @config end |
Class Method Details
.for(config) ⇒ Object
Factory method to create appropriate layout engine
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lutaml/xsd/spa/svg/layout_engine.rb', line 20 def self.for(config) case config.layout_type when "tree" Lutaml::Xsd::Spa::Svg::Layouts::TreeLayout.new(config) when "vertical" Lutaml::Xsd::Spa::Svg::Layouts::VerticalLayout.new(config) else raise ArgumentError, "Unknown layout type: #{config.layout_type}" end end |
Instance Method Details
#calculate(component_data, component_type) ⇒ LayoutResult
Calculates layout for the given component data
35 36 37 |
# File 'lib/lutaml/xsd/spa/svg/layout_engine.rb', line 35 def calculate(component_data, component_type) raise NotImplementedError, "#{self.class} must implement #calculate" end |