Sha256: 2c8ccc492c1aea66420809ba51f13870191174873a3c262da80279929b1b77e7

Contents?: true

Size: 881 Bytes

Versions: 7

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

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

    # Format text with color
    #
    # @param [String] text
    #
    # @return [String]
    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
      def format(text)
        text
      end

    private

      # Well rubocop you are static so you do not have a clue here ;)
      # rubocop:disable Style/RedundantInitialize
      # rubocop:disable Style/MissingSuper
      def initialize; end
      # rubocop:enable Style/RedundantInitialize
      # rubocop:enable Style/MissingSuper

    end.new

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

  end # Color
end # Unparser

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
unparser-0.6.15 lib/unparser/color.rb
unparser-0.6.14 lib/unparser/color.rb
unparser-0.6.13 lib/unparser/color.rb
unparser-0.6.12 lib/unparser/color.rb
unparser-0.6.10 lib/unparser/color.rb
unparser-0.6.9 lib/unparser/color.rb
unparser-0.6.8 lib/unparser/color.rb