Sha256: 17bdc97730c73f0d354460b4c3922db2d427a457f3034ccf7cf8850ebed5a2fc

Contents?: true

Size: 665 Bytes

Versions: 1

Compression:

Stored size: 665 Bytes

Contents

require 'colored'

def Colored!
  String.class_eval do
    Colored.instance_methods.each do |m|
      undef_method m
      define_method(m) do |*args|
        Colored.instance_method(m).bind(self).call(*args)
      end
    end
  end
end

module Colored
  class << self
    def not!
      String.class_eval do
        colors = COLORS.keys
        (
          EXTRAS.keys - %w[clear] +
          colors +
          colors.map { |c| "on_#{c}" } +
          colors.product(colors).reject { |p| p.inject(:==) }.map { |p| p.join '_on_' }
        ).map(&:to_sym).each do |m|
          undef_method m
          alias_method m, :dup
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
colored-not-1.2 lib/colored/not.rb