Sha256: 322ea17c2e07662f97645e64e32e33550b12651f5b23a18f9f517a5b0c5d6ff6

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

module CSVPP
  # Add core extensions here as refinements. Only load them when necessary, so
  # that we don't monkeypatch applications that load CSV++.
  #
  # @example Loading the core extensions to the current lexical scope
  #
  #   module MyScope
  #     using CSVPP::CoreExtensions
  #
  #     # Extensions exist here
  #
  #   end
  #
  #   # Extensions no longer exist here
  #
  module CoreExtensions
    refine String do
      def colorize(color_code)
        "\e[#{color_code}m#{self}\e[0m"
      end

      def green
        colorize 32
      end

      def blue
        colorize 34
      end

      def pink
        colorize 35
      end

      def yellow
        colorize 33
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csvpp-0.4.0 lib/csvpp/core_extensions.rb