module Elasticsearch::API::Response::Helpers::ColorHelper

Public Instance Methods

ansi(str, *codes) click to toggle source
# File lib/elasticsearch/api/response/helpers/color_helper.rb, line 26
def ansi(str, *codes)
  if colorized?
    str.to_s.ansi(*codes)
  else
    str.to_s
  end
end
colorized?() click to toggle source
# File lib/elasticsearch/api/response/helpers/color_helper.rb, line 6
def colorized?
  unless @ansi_loaded
    @colorized = load_ansi
  else
    !!@colorized
  end
end
disable_colorization() click to toggle source
# File lib/elasticsearch/api/response/helpers/color_helper.rb, line 14
def disable_colorization
  @ansi_loaded = true
  @colorized = false
end
load_ansi() click to toggle source
# File lib/elasticsearch/api/response/helpers/color_helper.rb, line 19
def load_ansi
  require "ansi/core"
  true
rescue LoadError
  false
end