8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/term/ansicolor/attribute/underline.rb', line 8
def underline(string = nil, color: nil, type: nil, &block)
code = {
nil => 4,
default: '4:1',
double: '4:2',
curly: '4:3',
dotted: '4:4',
dashed: '4:5',
}.fetch(type) { raise ArgumentError, "invalid line type" }
if color
a = Term::ANSIColor::Attribute[color]
color_code =
if rgb = a.ask_and_send(:to_rgb_triple).full?(:to_a)
"\e[58;2;#{rgb * ?;}"
else
raise ArgumentError, "invalid color #{a&.name.inspect}"
end
code = "#{code}m#{color_code}"
end
apply_code(code, string, &block)
end
|