From b4bff46d92da6319944b49a741ea9fa5620ea086 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 21 May 2019 06:02:54 +0900 Subject: [PATCH] define_method + yield would not work. Use Proc#call instead --- lib/aruba/colorizer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/aruba/colorizer.rb b/lib/aruba/colorizer.rb index 48b81fbc5..2c4fd2913 100644 --- a/lib/aruba/colorizer.rb +++ b/lib/aruba/colorizer.rb @@ -52,11 +52,11 @@ def self.coloring=(val) self.coloring = true ATTRIBUTES.each do |c, v| - define_method(c) do |string| + define_method(c) do |string, &block| result = '' result << "\e[#{v}m" if Aruba::AnsiColor.coloring? - if block_given? - result << yield + if block + result << block.call elsif string result << string elsif respond_to?(:to_str)