Class: Uniword::Resource::ColorSchemeLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/uniword/resource/color_scheme_loader.rb

Overview

Loads standalone color scheme YAML files from data/color_schemes/

Constant Summary collapse

DATA_DIR =
File.join(__dir__, "../../../data/color_schemes")

Class Method Summary collapse

Class Method Details

.available_schemesArray<String>

List all available bundled color schemes

Returns:

  • (Array<String>)

    Color scheme slugs



27
28
29
30
31
32
33
# File 'lib/uniword/resource/color_scheme_loader.rb', line 27

def self.available_schemes
  return [] unless Dir.exist?(DATA_DIR)

  Dir.glob(File.join(DATA_DIR, "*.yml"))
    .map { |p| File.basename(p, ".yml") }
    .sort
end

.load(name) ⇒ Themes::ColorScheme

Load a color scheme by name

Parameters:

  • name (String)

    Color scheme slug (e.g., “azure”, “emerald”)

Returns:

Raises:

  • (ArgumentError)

    if color scheme not found



14
15
16
17
18
19
20
21
22
# File 'lib/uniword/resource/color_scheme_loader.rb', line 14

def self.load(name)
  path = File.join(DATA_DIR, "#{name}.yml")
  unless File.exist?(path)
    raise ArgumentError,
          "Color scheme '#{name}' not found. Available: #{available_schemes.join(', ')}"
  end

  Themes::ColorScheme.from_yaml(File.read(path))
end