Sha256: 05abdb6d2eefe4793cef64ac0138a0eae1de8a1ae1514cc80a80b536a6204f4b

Contents?: true

Size: 374 Bytes

Versions: 16

Compression:

Stored size: 374 Bytes

Contents

module Paint
  # Standalone helpers which add functionality you sometimes need when working with terminal colors
  class << self
    # Removes any color and effect strings
    def unpaint(string)
      string.gsub(/\e\[(?:[0-9];?)+m/, '')
    end

    # Creates a random ANSI color
    def random(background = false)
      (background ? 40 : 30) + rand(8)
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/paint-2.2.1/lib/paint/util.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/paint-2.2.1/lib/paint/util.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/paint-2.2.1/lib/paint/util.rb
paint-2.2.1 lib/paint/util.rb
pokedex-terminal-0.2.8 vendor/bundle/ruby/2.7.0/gems/paint-2.2.0/lib/paint/util.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/paint-2.2.0/lib/paint/util.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/paint-2.2.0/lib/paint/util.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/paint-2.2.0/lib/paint/util.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/paint-2.2.0/lib/paint/util.rb
paint-2.2.0 lib/paint/util.rb
paint-2.1.1 lib/paint/util.rb
paint-2.1.0 lib/paint/util.rb
paint-2.0.3 lib/paint/util.rb
paint-2.0.2 lib/paint/util.rb
paint-2.0.1 lib/paint/util.rb
paint-2.0.0 lib/paint/util.rb