Sha256: fe9ded54e43ebdf9b3a1c05410d82b40d8e9d44be06609087f4ebd73b28c10f9

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

module Unparser
  # Class to colorize strings
  class Color
    include Adamantium::Flat, Concord.new(:code)

    # Format text with color
    #
    # @param [String] text
    #
    # @return [String]
    #
    # @api private
    #
    def format(text)
      "\e[#{code}m#{text}\e[0m"
    end

    NONE = Class.new(self) do

      # Format null color
      #
      # @param [String] text
      #
      # @return [String]
      #   the argument string
      #
      # @api private
      #
      def format(text)
        text
      end

    private

      # Initialize null color
      #
      # @return [undefined]
      #
      # @api private
      #
      def initialize; end

    end.new

    RED   = Color.new(31)
    GREEN = Color.new(32)
    BLUE  = Color.new(34)

  end # Color
end # Unparser

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unparser-0.2.8 lib/unparser/cli/color.rb
unparser-0.2.7 lib/unparser/cli/color.rb
unparser-0.2.6 lib/unparser/cli/color.rb