Sha256: 55b9fde00a334db667961a6c1f5a5ad973fc88c09589cbbaff3390ed84c997c8
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
module Term module ANSIColor class Attribute module Underline Attribute.set :underline, 4, skip_definition: true Attribute.set :underscore, 4, skip_definition: true # synonym for :underline 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 a.true_color? || a.rgb_color? || a.direct? color_code = "\e[58;2;#{a.rgb.to_a * ?;}" else raise ArgumentError, "invalid color #{a.name.inspect}" end code = "#{code}m#{color_code}" end apply_code(code, string, &block) end alias underscore underline end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
term-ansicolor-1.10.2 | lib/term/ansicolor/attribute/underline.rb |
term-ansicolor-1.10.1 | lib/term/ansicolor/attribute/underline.rb |