30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/wrapped_print.rb', line 30
def wp(label = nil, pattern: PATTERN, count: COUNT, prefix: nil, suffix: nil, color: nil)
line = pattern * count
color_method = detect_color_method(color)
logger_method = detect_logger_method
if block_given?
result = yield
result.tap do
logger_method.call color_method.call "#{prefix}#{line}"
logger_method.call color_method.call "#{label}#{result}"
logger_method.call color_method.call "#{line}#{suffix}"
end
else
self.tap do
logger_method.call color_method.call "#{prefix}#{line}"
logger_method.call color_method.call "#{label}#{self}"
logger_method.call color_method.call "#{line}#{suffix}"
end
end
end
|