Sha256: 87860a136979d5ff4a20068925e94b76d0415e35fa2625aa69ed682c6b2c26ac
Contents?: true
Size: 1023 Bytes
Versions: 5
Compression:
Stored size: 1023 Bytes
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 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 alias underscore underline end end end end
Version data entries
5 entries across 5 versions & 1 rubygems