Module: Elasticsearch::API::Response::ColorHelper
- Included in:
- ExplainRenderer
- Defined in:
- lib/elasticsearch/api/response/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
25 26 27 28 29 30 31 |
# File 'lib/elasticsearch/api/response/color_helper.rb', line 25 def ansi(str, *codes) if colorized? str.to_s.ansi(*codes) else str.to_s end end |
#colorized? ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'lib/elasticsearch/api/response/color_helper.rb', line 5 def colorized? unless @ansi_loaded @colorized = load_ansi else !!@colorized end end |
#disable_colorization ⇒ Object
13 14 15 16 |
# File 'lib/elasticsearch/api/response/color_helper.rb', line 13 def disable_colorization @ansi_loaded = true @colorized = false end |
#load_ansi ⇒ Object
18 19 20 21 22 23 |
# File 'lib/elasticsearch/api/response/color_helper.rb', line 18 def load_ansi require "ansi/core" true rescue LoadError false end |