Class: Uniword::Themes::ColorScheme

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/themes/theme.rb

Overview

Friendly Color Scheme - simplified color model

Represents colors as simple hex values, abstracting away OOXML complexity.

Examples:

scheme = ColorScheme.new(
  name: 'Atlas',
  colors: {
    accent1: 'F81B02',
    dk1: '000000',
    lt1: 'FFFFFF'
  }
)

Constant Summary collapse

KEY_ALIASES =

Key name aliases (maps snake_case to camelCase)

{
  fol_hlink: "folHlink",
}.freeze

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ String?

Convenience accessor for colors hash Handles both snake_case (:fol_hlink) and camelCase (‘folHlink’) keys

Parameters:

  • key (Symbol, String)

    Color key (:dk1, :lt1, :accent1, etc.)

Returns:

  • (String, nil)

    Hex color value or nil



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/uniword/themes/theme.rb', line 37

def [](key)
  key_str = key.to_s
  # Try exact match first
  result = colors&.[](key.to_sym) || colors&.[](key_str)
  return result if result

  # Try alias mapping
  if (aliased = KEY_ALIASES[key.to_sym])
    colors&.[](aliased.to_sym) || colors&.[](aliased)
  end
end

#[]=(key, value) ⇒ Object

Convenience setter for colors hash

Parameters:

  • key (Symbol)

    Color key

  • value (String)

    Hex color value



53
54
55
56
# File 'lib/uniword/themes/theme.rb', line 53

def []=(key, value)
  self.colors ||= {}
  colors[key.to_sym] = value
end