From 6e97a96d3ba23bafa60a825b5d30f3b00b5971a4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@ruby-lang.org> Date: Mon, 8 Apr 2024 18:28:34 +0900 Subject: [PATCH] Tell if the block is given by block argument --- lib/tmpdir.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb index 967a011..604051a 100644 --- a/lib/tmpdir.rb +++ b/lib/tmpdir.rb @@ -98,13 +98,13 @@ def self.tmpdir # FileUtils.remove_entry dir # end # - def self.mktmpdir(prefix_suffix=nil, *rest, **options) + def self.mktmpdir(prefix_suffix=nil, *rest, **options, &block) base = nil path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|path, _, _, d| base = d mkdir(path, 0700) } - if block_given? + if block begin yield path.dup ensure