Sha256: ab4c9694d02b9d58924a31e06d6cc616dab5fd6a89221d25b7e87d5c4f721981
Contents?: true
Size: 695 Bytes
Versions: 1
Compression:
Stored size: 695 Bytes
Contents
module ColorRoutes # Some extensions to String to deal with ANSI colors. module StringANSI COLORS = { :black => 30, :red => 31, :green => 32, :brown => 33, :blue => 34, :magenta => 35, :cyan => 36, :gray => 37 } def color(color) code = "\033[#{COLORS[color]}m" end_code = "\033[0m" "#{code}#{self}#{end_code}" end def ansi_length gsub(/\033\[\d+m/, "").length end def ansi_ljust(n) ljust(n + length - ansi_length) end def ansi_rjust(n) rjust(n + length - ansi_length) end end end class String include ColorRoutes::StringANSI end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
color_routes-0.0.2 | lib/color_routes/string_ansi.rb |