Class: Colorable::ColorSpace
- Inherits:
-
Object
- Object
- Colorable::ColorSpace
show all
- Includes:
- Converter, Comparable
- Defined in:
- lib/colorable/color_space.rb
Instance Method Summary
collapse
Methods included from Converter
#hex2rgb, #hsb2rgb, #name2rgb, #rgb2hex, #rgb2hsb, #rgb2hsl, #rgb2name
Instance Method Details
#+(arg) ⇒ Object
15
16
17
|
# File 'lib/colorable/color_space.rb', line 15
def +(arg)
raise "Subclass must implement it"
end
|
#-(arg) ⇒ Object
19
20
21
22
|
# File 'lib/colorable/color_space.rb', line 19
def -(arg)
arg = arg.is_a?(Fixnum) ? -arg : arg.map(&:-@)
self + arg
end
|
#<=>(other) ⇒ Object
6
7
8
|
# File 'lib/colorable/color_space.rb', line 6
def <=>(other)
self.to_a <=> other.to_a
end
|
#coerce(arg) ⇒ Object
24
25
26
|
# File 'lib/colorable/color_space.rb', line 24
def coerce(arg)
[self, arg]
end
|
#move_to_top(idx) ⇒ Object
10
11
12
13
|
# File 'lib/colorable/color_space.rb', line 10
def move_to_top(idx)
arr = self.to_a
arr.insert 0, arr.delete_at(idx)
end
|
#to_s ⇒ Object
28
29
30
31
|
# File 'lib/colorable/color_space.rb', line 28
def to_s
name = "#{self.class}"[/\w+$/].downcase
"#{name}(%i,%i,%i)" % to_a
end
|