Class: Unmagic::Color::RGB::Named
- Inherits:
-
Object
- Object
- Unmagic::Color::RGB::Named
- Defined in:
- lib/unmagic/color/rgb/named.rb
Overview
Named colors support for RGB colors.
Provides access to standard named colors (like “red”, “blue”, “goldenrod”) and converts them to RGB color instances.
Defined Under Namespace
Classes: ParseError
Class Method Summary collapse
-
.all ⇒ Array<String>
Get all available color names.
-
.parse(name) ⇒ RGB
Parse a named color and return its RGB representation.
-
.valid?(name) ⇒ Boolean
Check if a color name is valid.
Class Method Details
.all ⇒ Array<String>
Get all available color names.
69 70 71 |
# File 'lib/unmagic/color/rgb/named.rb', line 69 def all data.keys end |
.parse(name) ⇒ RGB
Parse a named color and return its RGB representation.
40 41 42 43 44 45 46 47 |
# File 'lib/unmagic/color/rgb/named.rb', line 40 def parse(name) normalized_name = normalize_name(name) hex_value = data[normalized_name] raise ParseError, "Unknown color name: #{name.inspect}" unless hex_value Hex.parse(hex_value) end |
.valid?(name) ⇒ Boolean
Check if a color name is valid.
57 58 59 60 |
# File 'lib/unmagic/color/rgb/named.rb', line 57 def valid?(name) normalized_name = normalize_name(name) data.key?(normalized_name) end |