Sha256: 16ed67949494e21ed89d3711d40431d2d5b282f99fcd39b41a7884d4de678ad7
Contents?: true
Size: 529 Bytes
Versions: 7
Compression:
Stored size: 529 Bytes
Contents
class String COLORS = { :red => 31, :green => 32, :yellow => 33, :blue => 34, :magenta => 35, :cyan => 36, :white => 39, :gray => 90 } COLORS.keys.each do |color| define_method color do colorize color end end def indent(n, string = " ") split("\n").collect do |line| line.empty? ? line : "#{string * n}#{line}" end.join("\n") end private def colorize(color) color = COLORS[color] "\033[0;#{color}m#{self}\033[0m" end end
Version data entries
7 entries across 7 versions & 1 rubygems