Class: Lutaml::Xsd::Spa::Svg::StyleConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/spa/svg/style_configuration.rb

Overview

Loads and provides access to SVG styling configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(styles_hash, rules_hash = {}) ⇒ StyleConfiguration

Returns a new instance of StyleConfiguration.



31
32
33
34
35
36
37
38
39
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 31

def initialize(styles_hash, rules_hash = {})
  @colors = Config::ColorScheme.new(styles_hash["colors"] || {})
  @dimensions = Config::Dimensions.new(styles_hash["dimensions"] || {})
  @effects = Config::Effects.new(styles_hash["effects"] || {})
  @connectors = Config::ConnectorStyles.new(styles_hash["connectors"] || {})
  @layout_config = Config::LayoutConfig.new(styles_hash["layout"] || {})
  @component_rules = Config::ComponentRules.new(rules_hash["components"] || {})
  @indicator_rules = Config::IndicatorRules.new(rules_hash["indicators"] || {})
end

Instance Attribute Details

#colorsObject (readonly)

Returns the value of attribute colors.



18
19
20
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 18

def colors
  @colors
end

#connectorsObject (readonly)

Returns the value of attribute connectors.



18
19
20
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 18

def connectors
  @connectors
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



18
19
20
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 18

def dimensions
  @dimensions
end

#effectsObject (readonly)

Returns the value of attribute effects.



18
19
20
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 18

def effects
  @effects
end

#layout_configObject (readonly)

Returns the value of attribute layout_config.



18
19
20
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 18

def layout_config
  @layout_config
end

Class Method Details

.default_rules_pathObject



57
58
59
60
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 57

def self.default_rules_path
  File.join(__dir__,
            "../../../../../config/spa/svg_component_rules.yml")
end

.default_styles_pathObject



53
54
55
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 53

def self.default_styles_path
  File.join(__dir__, "../../../../../config/spa/svg_styles.yml")
end

.load(styles_path = nil, rules_path = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 21

def self.load(styles_path = nil, rules_path = nil)
  styles_path ||= default_styles_path
  rules_path ||= default_rules_path

  styles = YAML.load_file(styles_path)
  rules = File.exist?(rules_path) ? YAML.load_file(rules_path) : {}

  new(styles, rules)
end

Instance Method Details

#component_rule(component_type) ⇒ Object



45
46
47
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 45

def component_rule(component_type)
  @component_rules.rule_for(component_type)
end

#indicator_rule(indicator_type) ⇒ Object



49
50
51
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 49

def indicator_rule(indicator_type)
  @indicator_rules.rule_for(indicator_type)
end

#layout_typeObject



41
42
43
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 41

def layout_type
  @layout_config.default
end