diff options
Diffstat (limited to 'lib/highline/string_extensions.rb')
-rw-r--r-- | lib/highline/string_extensions.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/highline/string_extensions.rb b/lib/highline/string_extensions.rb index 95c8bd5..5c50977 100644 --- a/lib/highline/string_extensions.rb +++ b/lib/highline/string_extensions.rb @@ -61,15 +61,25 @@ class HighLine if method.to_s =~ /^(on_)?rgb_([0-9a-fA-F]{6})$/ color(method) else - raise NoMethodError, "undefined method `#{method}' for #<#{self.class}:#{format('%#x', object_id)}>" + raise NoMethodError, "undefined method `#{method}' for" / + "#<#{self.class}:#{format('%#x', object_id)}>" end end private def setup_color_code(*colors) - color_code = colors.map { |color| color.is_a?(Numeric) ? format('%02x', color) : color.to_s }.join - raise "Bad RGB color #{colors.inspect}" unless color_code =~ /^[a-fA-F0-9]{6}/ + color_code = colors.map do |color| + if color.is_a?(Numeric) + format('%02x', color) + else + color.to_s + end + end.join + + raise "Bad RGB color #{colors.inspect}" unless + color_code =~ /^[a-fA-F0-9]{6}/ + color_code end end |