Module: Color::RGB::JP::Base::Pallet
- Includes:
- Encode, Enumerable
- Defined in:
- lib/color/rgb/jp/base/pallet.rb
Constant Summary
Constants included
from Encode
Encode::INTERNAL_ENCODING
Instance Method Summary
collapse
Methods included from Encode
encode_to, with_internal_encoding
Instance Method Details
#[](name, encoding = nil) ⇒ Object
21
22
23
24
25
|
# File 'lib/color/rgb/jp/base/pallet.rb', line 21
def [](name, encoding = nil)
with_internal_encoding(name, encoding) {|n|
@index[normalize(n)]
}
end
|
#colors ⇒ Object
13
14
15
|
# File 'lib/color/rgb/jp/base/pallet.rb', line 13
def colors
@colors
end
|
#define_color(const, hex, *names) ⇒ Object
Also known as:
c
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/color/rgb/jp/base/pallet.rb', line 27
def define_color(const, hex, *names)
@colors ||= []
@index ||= {}
name = ColorName.new(const, *names)
rgb = ::Color::RGB.from_html(hex)
color = NamedRGB.new(name, rgb)
@colors << color
[const, *names].compact.each {|e|
@index[normalize(e)] ||= color
}
color
end
|
#each(&block) ⇒ Object
17
18
19
|
# File 'lib/color/rgb/jp/base/pallet.rb', line 17
def each(&block)
colors.each(&block)
end
|