Class: DrawioDsl::Schema::Diagram
- Inherits:
-
Object
- Object
- DrawioDsl::Schema::Diagram
- Defined in:
- lib/drawio_dsl/schema/diagram.rb
Overview
Diagram is the root of the schema, it contains pages
Instance Attribute Summary collapse
-
#bg_theme ⇒ Object
Returns the value of attribute bg_theme.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#palette ⇒ Object
Returns the value of attribute palette.
-
#style ⇒ Object
Returns the value of attribute style.
-
#theme ⇒ Object
Returns the value of attribute theme.
Instance Method Summary collapse
- #bg_theme_palette ⇒ Object
-
#initialize(**args) ⇒ Diagram
constructor
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
-
#theme_palette ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #to_h ⇒ Object
Constructor Details
#initialize(**args) ⇒ Diagram
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 15 def initialize(**args) @host = args[:host] || SecureRandom.alphanumeric(3) @theme = args[:theme] || :style_02 @bg_theme = args[:bg_theme] || :snow @style = DrawioDsl::Schema::CommonStyle.new(**args) do default_style = KConfig.configuration.drawio.base_style # Inherit from configured style when specific style not specified. @white_space ||= default_style.white_space @html ||= default_style.html @rounded ||= default_style.rounded @shadow ||= default_style.shadow @sketch ||= default_style.sketch @glass ||= default_style.glass end @palette = DrawioDsl::Schema::DefaultPalette.new(self, **args) do |diagram| @fill_color ||= diagram.theme_palette.fill_color @stroke_color ||= diagram.theme_palette.stroke_color @font_color ||= diagram.theme_palette.font_color @gradient ||= diagram.theme_palette.gradient end @pages = args[:pages] || [] end |
Instance Attribute Details
#bg_theme ⇒ Object
Returns the value of attribute bg_theme.
9 10 11 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 9 def bg_theme @bg_theme end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 7 def host @host end |
#pages ⇒ Object
Returns the value of attribute pages.
12 13 14 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 12 def pages @pages end |
#palette ⇒ Object
Returns the value of attribute palette.
11 12 13 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 11 def palette @palette end |
#style ⇒ Object
Returns the value of attribute style.
10 11 12 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 10 def style @style end |
#theme ⇒ Object
Returns the value of attribute theme.
8 9 10 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 8 def theme @theme end |
Instance Method Details
#bg_theme_palette ⇒ Object
47 48 49 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 47 def bg_theme_palette @bg_theme_palette ||= KConfig.configuration.drawio.theme.background(bg_theme) end |
#theme_palette ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
43 44 45 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 43 def theme_palette @theme_palette ||= KConfig.configuration.drawio.theme.element(theme) end |
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/drawio_dsl/schema/diagram.rb', line 51 def to_h { host: host, theme: theme, palette: palette.to_h, style: style.to_h, pages: pages.select(&:active?).map(&:to_h) } end |