summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-22 04:44:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-22 04:44:19 +0000
commit2e2522ecdfc577f8c44850cf8ba616f456730cf7 (patch)
tree7315d2fe43077f55fe6478bb09894e0f53935eb1
parent565fef821069ac0ef50359e372eef3ba14ce69be (diff)
tmpdir.rb: explicit conversion to string
* lib/tmpdir.rb (Dir::Tmpname#make_tmpname): convert prefix and suffix to strings explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/tmpdir.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 7bd99e1..f52d092 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -106,6 +106,10 @@ class Dir
end
def make_tmpname((prefix, suffix), n)
+ prefix = (String.try_convert(prefix) or
+ raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
+ suffix &&= (String.try_convert(suffix) or
+ raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
t = Time.now.strftime("%Y%m%d")
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
path << "-#{n}" if n