Module: DogWatch::Model::Mixin::Colorize
- Included in:
- Response
- Defined in:
- lib/dogwatch/model/mixin/colorize.rb
Overview
Provides a colorize() mixin that handles shell output coloring
Instance Method Summary collapse
Instance Method Details
#colorize(param, options = {}) ⇒ Symbol
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dogwatch/model/mixin/colorize.rb', line 11 def colorize(param, = {}) define_method(:color) do case instance_variable_get("@#{ param }") when *.fetch(:white, [:status]) then :white when *.fetch(:cyan, [:debug, :trace]) then :cyan when *.fetch(:green, [:info, :success, :create]) then :green when *.fetch(:yellow, [:warn, :update]) then :yellow when *.fetch(:red, [:error, :fail, :delete]) then :red else .fetch(:default, :green) end end end |