Sha256: 92f501b81bf6e57aa86fa343b876eeca23723b1139c9875791e61cff767b19c0

Contents?: true

Size: 504 Bytes

Versions: 1

Compression:

Stored size: 504 Bytes

Contents

# Patch for Ruby's String class
class String
  def canonicalize
    URLCanonicalize.canonicalize(self)
  end

  def ansi_attributes(*args)
    "\e[#{args.join(';')}m#{self}\e[0m"
  end

  colors = %w(black red green yellow blue magenta cyan white)

  colors.each_with_index do |fg_color, i|
    fg = 30 + i
    define_method(fg_color) { ansi_attributes(fg) }

    colors.each_with_index do |bg_color, j|
      define_method("#{fg_color}_on_#{bg_color}") { ansi_attributes(fg, 40 + j) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url_canonicalize-0.0.1 lib/monkey_patches/string.rb