Class: Uniword::Resource::ColorSchemeLoader
- Inherits:
-
Object
- Object
- Uniword::Resource::ColorSchemeLoader
- 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
-
.available_schemes ⇒ Array<String>
List all available bundled color schemes.
-
.load(name) ⇒ Themes::ColorScheme
Load a color scheme by name.
Class Method Details
.available_schemes ⇒ Array<String>
List all available bundled color schemes
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
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 |