Class: String
- Inherits:
-
Object
- Object
- String
- Includes:
- Term::ANSIColor, Yummi::OnBox
- Defined in:
- lib/yummi/extensions.rb
Instance Method Summary collapse
-
#colorize(params) ⇒ Object
Colorizes the string using #Yummi#colorize.
Methods included from Yummi::OnBox
Instance Method Details
#colorize(params) ⇒ Object
Colorizes the string using #Yummi#colorize
If params is a hash, the keys will be used as a regexp and the result of #gsub will be colorized using the value color.
Otherwise, the params will be sended to Yummi#colorize
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/yummi/extensions.rb', line 52 def colorize params if params.is_a? Hash text = self params.each do |regexp, color| text = text.gsub(regexp, "\\0".colorize(color)) end return text end Yummi::colorize self, params end |