Class: Cogger::Formatters::Color

Inherits:
Abstract
  • Object
show all
Defined in:
lib/cogger/formatters/color.rb

Overview

Formats by color.

Direct Known Subclasses

Emoji

Constant Summary collapse

TEMPLATE =
"<dynamic>[%<id>s]</dynamic> %<message:dynamic>s"

Constants inherited from Abstract

Abstract::NEW_LINE, Abstract::SANITIZERS

Instance Method Summary collapse

Constructor Details

#initialize(template = TEMPLATE, parser: Parsers::Combined.new) ⇒ Color

Returns a new instance of Color.



9
10
11
12
13
# File 'lib/cogger/formatters/color.rb', line 9

def initialize template = TEMPLATE, parser: Parsers::Combined.new
  super()
  @template = template
  @parser = parser
end

Instance Method Details

#call(*input) ⇒ Object



15
16
17
18
19
20
# File 'lib/cogger/formatters/color.rb', line 15

def call(*input)
  *, entry = input
  attributes = sanitize entry, :tagged

  format(parse(attributes[:level]), attributes).tap(&:strip!) << NEW_LINE
end