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)


25
26
27
28
# File 'lib/logbert/formatters.rb', line 25

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

Instance Attribute Details

#proc ⇒ Object

Returns the value of attribute proc.



23
24
25
# File 'lib/logbert/formatters.rb', line 23

def proc
  @proc
end

Instance Method Details

#format(msg) ⇒ Object



30
31
32
# File 'lib/logbert/formatters.rb', line 30

def format(msg)
  @proc.call msg
end