Class: Cogger::Formatters::Transformers::Color
- Inherits:
-
Object
- Object
- Cogger::Formatters::Transformers::Color
- Defined in:
- lib/cogger/formatters/transformers/color.rb
Overview
Transforms target into colorized string.
Instance Method Summary collapse
- #call(target, directive, level) ⇒ Object
-
#initialize(emoji: Emoji::KEY, key_transformer: Key, registry: Cogger) ⇒ Color
constructor
A new instance of Color.
Constructor Details
#initialize(emoji: Emoji::KEY, key_transformer: Key, registry: Cogger) ⇒ Color
Returns a new instance of Color.
8 9 10 11 12 |
# File 'lib/cogger/formatters/transformers/color.rb', line 8 def initialize emoji: Emoji::KEY, key_transformer: Key, registry: Cogger @emoji = emoji @key_transformer = key_transformer @registry = registry end |
Instance Method Details
#call(target, directive, level) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cogger/formatters/transformers/color.rb', line 14 def call target, directive, level return target if !target.is_a?(String) || target == emoji key = key_transformer.call directive, level return client.encode target, key if aliases.key?(key) || defaults.key?(key) target end |