Module: AwesomePrint::Colorize
- Included in:
- Formatter, Formatters::BaseFormatter
- Defined in:
- lib/awesome_print/colorize.rb
Instance Method Summary collapse
-
#colorize(str, type) ⇒ Object
Pick the color and apply it to the given string as necessary.
Instance Method Details
#colorize(str, type) ⇒ Object
Pick the color and apply it to the given string as necessary.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/awesome_print/colorize.rb', line 8 def colorize(str, type) str = CGI.escapeHTML(str) if [:html] if [:plain] || ![:color][type] || !inspector.colorize? str # # Check if the string color method is defined by awesome_print and accepts # html parameter or it has been overriden by some gem such as colorize. # elsif str.method([:color][type]).arity == -1 # Accepts html parameter. str.send([:color][type], [:html]) else str = %Q|<kbd style="color:#{[:color][type]}">#{str}</kbd>| if [:html] str.send([:color][type]) end end |