Class: Rainbow::Color::Named
- Inherits:
-
Indexed
- Object
- Rainbow::Color
- Indexed
- Rainbow::Color::Named
- 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 }.freeze
Instance Attribute Summary
Attributes inherited from Indexed
Attributes inherited from Rainbow::Color
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ground, name) ⇒ Named
constructor
A new instance of Named.
Methods inherited from Indexed
Methods inherited from Rainbow::Color
Constructor Details
#initialize(ground, name) ⇒ Named
Returns a new instance of Named.
90 91 92 93 94 95 96 97 |
# File 'lib/rainbow/color.rb', line 90 def initialize(ground, name) unless Named.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_names ⇒ Object
82 83 84 |
# File 'lib/rainbow/color.rb', line 82 def self.color_names NAMES.keys end |
.valid_names ⇒ Object
86 87 88 |
# File 'lib/rainbow/color.rb', line 86 def self.valid_names color_names.join(', ') end |