Sha256: 3db18c1e044029664963492e273fa4c8ef2e4f1ecc4840704d49ba56dc631785

Contents?: true

Size: 1.09 KB

Versions: 28

Compression:

Stored size: 1.09 KB

Contents

# typed: strict
# frozen_string_literal: true

module Spoom
  class Color < T::Enum
    extend T::Sig

    enums do
      CLEAR           = new("\e[0m")
      BOLD            = new("\e[1m")

      BLACK           = new("\e[30m")
      RED             = new("\e[31m")
      GREEN           = new("\e[32m")
      YELLOW          = new("\e[33m")
      BLUE            = new("\e[34m")
      MAGENTA         = new("\e[35m")
      CYAN            = new("\e[36m")
      WHITE           = new("\e[37m")

      LIGHT_BLACK     = new("\e[90m")
      LIGHT_RED       = new("\e[91m")
      LIGHT_GREEN     = new("\e[92m")
      LIGHT_YELLOW    = new("\e[93m")
      LIGHT_BLUE      = new("\e[94m")
      LIGHT_MAGENTA   = new("\e[95m")
      LIGHT_CYAN      = new("\e[96m")
      LIGHT_WHITE     = new("\e[97m")
    end

    sig { returns(String) }
    def ansi_code
      serialize
    end
  end

  module Colorize
    extend T::Sig

    sig { params(string: String, color: Color).returns(String) }
    def set_color(string, *color)
      "#{color.map(&:ansi_code).join}#{string}#{Color::CLEAR.ansi_code}"
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
spoom-1.5.2 lib/spoom/colors.rb
spoom-1.5.1 lib/spoom/colors.rb
spoom-1.5.0 lib/spoom/colors.rb
spoom-1.4.2 lib/spoom/colors.rb
spoom-1.4.1 lib/spoom/colors.rb
spoom-1.4.0 lib/spoom/colors.rb
spoom-1.3.3 lib/spoom/colors.rb
spoom-1.3.2 lib/spoom/colors.rb
spoom-1.3.1 lib/spoom/colors.rb
spoom-1.3.0 lib/spoom/colors.rb
spoom-1.2.4 lib/spoom/colors.rb
spoom-1.2.3 lib/spoom/colors.rb
spoom-1.2.2 lib/spoom/colors.rb
spoom-1.2.1 lib/spoom/colors.rb
spoom-1.2.0 lib/spoom/colors.rb
spoom-1.1.16 lib/spoom/colors.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/spoom-1.1.15/lib/spoom/colors.rb
spoom-1.1.15 lib/spoom/colors.rb
spoom-1.1.14 lib/spoom/colors.rb
spoom-1.1.13 lib/spoom/colors.rb