Class: Lutaml::Xsd::Spa::Svg::StyleConfiguration
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Spa::Svg::StyleConfiguration
- Defined in:
- lib/lutaml/xsd/spa/svg/style_configuration.rb
Overview
Loads and provides access to SVG styling configuration
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#connectors ⇒ Object
readonly
Returns the value of attribute connectors.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#effects ⇒ Object
readonly
Returns the value of attribute effects.
-
#layout_config ⇒ Object
readonly
Returns the value of attribute layout_config.
Class Method Summary collapse
- .default_rules_path ⇒ Object
- .default_styles_path ⇒ Object
- .load(styles_path = nil, rules_path = nil) ⇒ Object
Instance Method Summary collapse
- #component_rule(component_type) ⇒ Object
- #indicator_rule(indicator_type) ⇒ Object
-
#initialize(styles_hash, rules_hash = {}) ⇒ StyleConfiguration
constructor
A new instance of StyleConfiguration.
- #layout_type ⇒ Object
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
#colors ⇒ Object (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 |
#connectors ⇒ Object (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 |
#dimensions ⇒ Object (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 |
#effects ⇒ Object (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_config ⇒ Object (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_path ⇒ Object
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_path ⇒ Object
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_type ⇒ Object
41 42 43 |
# File 'lib/lutaml/xsd/spa/svg/style_configuration.rb', line 41 def layout_type @layout_config.default end |