Class: Rainbow::Color::Named

Inherits:
Indexed show all
Defined in:
lib/rainbow/color.rb

Constant Summary collapse

NAMES =
{
  :black   => 0,
  :red     => 1,
  :green   => 2,
  :yellow  => 3,
  :blue    => 4,
  :magenta => 5,
  :cyan    => 6,
  :white   => 7,
  :default => 9,
}

Instance Attribute Summary

Attributes inherited from Indexed

#num

Attributes inherited from Rainbow::Color

#ground

Instance Method Summary collapse

Methods inherited from Indexed

#codes

Methods inherited from Rainbow::Color

build, parse_hex_color

Constructor Details

#initialize(ground, name) ⇒ Named

Returns a new instance of Named.

Raises:

  • (ArgumentError)


61
62
63
64
65
66
67
# File 'lib/rainbow/color.rb', line 61

def initialize(ground, name)
  raise ArgumentError.new(
    "Unknown color name, valid names: #{color_names.join(', ')}"
  ) unless color_names.include?(name)

  super(ground, NAMES[name])
end