Class: Ea::Model::Diagram
- Defined in:
- lib/ea/model/diagram.rb
Overview
A diagram: an ordered set of placed elements and connectors. The diagram references the package it belongs to (by id) and owns its elements/connectors compositionally.
Instance Method Summary collapse
-
#display_config ⇒ Ea::Diagram::DisplayConfig
Returns the DisplayConfig parsed from style + style_ex.
-
#style_ex_flags ⇒ Object
Parses style_ex into a Hash of flag => value.
-
#theme ⇒ Ea::Theme::Definition
Returns the resolved Theme Definition.
-
#theme=(value) ⇒ Object
Set the diagram's theme.
-
#theme_id ⇒ String?
Returns the effective theme ID.
Instance Method Details
#display_config ⇒ Ea::Diagram::DisplayConfig
Returns the DisplayConfig parsed from style + style_ex. Controls behavioral rendering flags (HideAtts, HideOps, SuppressFOC, AttPub, ShowNotes, etc.).
79 80 81 |
# File 'lib/ea/model/diagram.rb', line 79 def display_config Ea::Diagram::DisplayConfig.from_style(style:, style_ex:) end |
#style_ex_flags ⇒ Object
Parses style_ex into a Hash of flag => value. Returns empty Hash when style_ex is nil/empty.
Example: "Theme=:119;SuppressFOC=1;AttPkg=1" → { "Theme" => ":119", "SuppressFOC" => "1", "AttPkg" => "1" }
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ea/model/diagram.rb', line 46 def style_ex_flags return {} if style_ex.nil? || style_ex.empty? style_ex.split(";").filter_map do |pair| next nil unless pair.include?("=") key, value = pair.split("=", 2) [key, value.to_s] if key && !key.empty? end.to_h end |
#theme ⇒ Ea::Theme::Definition
Returns the resolved Theme Definition. Looks up from the Registry by theme_id, falling back to default.
70 71 72 |
# File 'lib/ea/model/diagram.rb', line 70 def theme Ea::Theme::Registry.lookup(theme_id) end |
#theme=(value) ⇒ Object
Set the diagram's theme. Accepts:
diagram.theme = :119 # by Symbol ID
diagram.theme = ":119" # by String ID
diagram.theme = "119" # by String ID (no colon)
diagram.theme = definition # by Definition object
When given an ID, sets theme_override_id. When given a Definition, registers it in the Registry and stores its ID.
94 95 96 97 98 99 100 101 102 |
# File 'lib/ea/model/diagram.rb', line 94 def theme=(value) case value when Ea::Theme::Definition Ea::Theme::Registry.register(value) @theme_override_id = value.id else @theme_override_id = normalize_theme_id(value) end end |
#theme_id ⇒ String?
Returns the effective theme ID. Resolved from (in order):
1. theme_override_id (set by theme=)
2. style_ex_flags["Theme"]
62 63 64 |
# File 'lib/ea/model/diagram.rb', line 62 def theme_id theme_override_id || style_ex_flags["Theme"] end |