Sha256: b2ef1a34a771131eaf98fe239f54418951b1b470607b21076783d86988f7c583

Contents?: true

Size: 576 Bytes

Versions: 5

Compression:

Stored size: 576 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

module Aurb
  module CoreExt
    module String
      # Colors a string with +color+.
      # Uses the ANSICode library provided by +facets+.
      #
      #   "Hello".colorize(:blue) # => "\e[34mHello\e[0m"
      #
      # For more information on available effects, see
      # http://facets.rubyforge.org/apidoc/api/more/classes/ANSICode.html
      def colorize(effect)
        ANSI::Code.send(effect.to_sym) << self << ANSI::Code.clear
      rescue
        self
      end
    end
  end
end

String.send :include, Aurb::CoreExt::String

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aurb-1.3.0 lib/aurb/core_ext/string.rb
aurb-1.2.4 lib/aurb/core_ext/string.rb
aurb-1.2.3 lib/aurb/core_ext/string.rb
aurb-1.2.2 lib/aurb/core_ext/string.rb
aurb-1.2.1 lib/aurb/core_ext/string.rb