Class: Rainbow::Color::X11Named

Inherits:
RGB show all
Includes:
X11ColorNames
Defined in:
lib/rainbow/color.rb

Constant Summary

Constants included from X11ColorNames

X11ColorNames::NAMES

Instance Attribute Summary

Attributes inherited from RGB

#b, #g, #r

Attributes inherited from Indexed

#num

Attributes inherited from Rainbow::Color

#ground

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RGB

#codes, to_ansi_domain

Methods inherited from Indexed

#codes

Methods inherited from Rainbow::Color

build, parse_hex_color

Constructor Details

#initialize(ground, name) ⇒ X11Named

Returns a new instance of X11Named.



140
141
142
143
144
145
146
147
# File 'lib/rainbow/color.rb', line 140

def initialize(ground, name)
  unless X11Named.color_names.include?(name)
    raise ArgumentError,
          "Unknown color name, valid names: #{self.class.valid_names}"
  end

  super(ground, *NAMES[name])
end

Class Method Details

.color_namesObject



132
133
134
# File 'lib/rainbow/color.rb', line 132

def self.color_names
  NAMES.keys
end

.valid_namesObject



136
137
138
# File 'lib/rainbow/color.rb', line 136

def self.valid_names
  color_names.join(', ')
end