Module: Elasticsearch::API::Response::Helpers::ColorHelper
- Included in:
- Renderers::BaseRenderer
- Defined in:
- lib/elasticsearch/api/response/helpers/color_helper.rb
Instance Method Summary collapse
- #ansi(str, *codes) ⇒ Object
- #colorized? ⇒ Boolean
- #disable_colorization ⇒ Object
- #load_ansi ⇒ Object
Instance Method Details
#ansi(str, *codes) ⇒ Object
26 27 28 29 30 31 32 |
# 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? ⇒ Boolean
6 7 8 9 10 11 12 |
# 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 ⇒ Object
14 15 16 17 |
# File 'lib/elasticsearch/api/response/helpers/color_helper.rb', line 14 def disable_colorization @ansi_loaded = true @colorized = false end |
#load_ansi ⇒ Object
19 20 21 22 23 24 |
# File 'lib/elasticsearch/api/response/helpers/color_helper.rb', line 19 def load_ansi require "ansi/core" true rescue LoadError false end |