Class: Logbert::Formatters::ProcFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/logbert/formatters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ProcFormatter

Returns a new instance of ProcFormatter.

Raises:

  • (ArgumentError)


38
39
40
41
# File 'lib/logbert/formatters.rb', line 38

def initialize(&block)
  raise ArgumentError, "ProcFormatter must be initialized with a block" unless block_given?
  @proc = block
end

Instance Attribute Details

#procObject

Returns the value of attribute proc.



36
37
38
# File 'lib/logbert/formatters.rb', line 36

def proc
  @proc
end

Instance Method Details

#format(msg) ⇒ Object



43
44
45
# File 'lib/logbert/formatters.rb', line 43

def format(msg)
  @proc.call msg
end