Class: SuperDiff::Csi::Color
- Inherits:
-
Object
- Object
- SuperDiff::Csi::Color
show all
- Defined in:
- lib/super_diff/csi/color.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.exists?(name) ⇒ Boolean
6
7
8
|
# File 'lib/super_diff/csi/color.rb', line 6
def self.exists?(name)
FourBitColor.exists?(name)
end
|
.resolve(value, layer:) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/super_diff/csi/color.rb', line 10
def self.resolve(value, layer:)
if value.is_a?(Symbol)
FourBitColor.new(value, layer: layer)
else
TwentyFourBitColor.new(value, layer: layer)
end
end
|
.sub_colorized_areas_in(text) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/super_diff/csi/color.rb', line 18
def self.sub_colorized_areas_in(text)
regex = /(#{opening_regex.source.gsub(/\((.+?)\)/, '\1')})(.+?)\e\[0m/
text.gsub(regex) do
match = Regexp.last_match
if match[1] == "\e[0m"
match[0]
else
yield match[2], new(match[1])
end
end
end
|
Instance Method Details
#background? ⇒ Boolean
40
41
42
|
# File 'lib/super_diff/csi/color.rb', line 40
def background?
layer == :background
end
|
#foreground? ⇒ Boolean
36
37
38
|
# File 'lib/super_diff/csi/color.rb', line 36
def foreground?
layer == :foreground
end
|
#to_foreground ⇒ Object
44
45
46
|
# File 'lib/super_diff/csi/color.rb', line 44
def to_foreground
raise NotImplementedError
end
|
#to_s ⇒ Object
32
33
34
|
# File 'lib/super_diff/csi/color.rb', line 32
def to_s
raise NotImplementedError
end
|