Sha256: 30131fb379e635115b70573ef0e04dedf8fc85455aca6b251ff4d2880293521c

Contents?: true

Size: 386 Bytes

Versions: 3

Compression:

Stored size: 386 Bytes

Contents

module Hscode
  class PrettyPrint
    COLORS = {
      '0' => 255,
      '1' => 6,
      '2' => 2,
      '3' => 3,
      '4' => 9,
      '5' => 1
    }.freeze

    def self.print(text, colour_code)
      puts make_pretty(text, COLORS[colour_code])
    end

    private_class_method

    def self.make_pretty(text, color_code)
      "\x1b[38;5;#{color_code}m#{text}\n"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hscode-0.1.2 lib/hscode/pretty_print.rb
hscode-0.1.1 lib/hscode/pretty_print.rb
hscode-0.1.0 lib/hscode/pretty_print.rb