siamii
siamii

Reputation: 24134

Tempfile generation with different pattern

I'm creating a Tempfile like this

Tempfile.new("myfile.txt")

This creates a file like this

TempDir/myfile.txt20120210-1696-yd53si

but I need it to create it like this

TempDir/20120210-1696-yd53si/myfile.txt

How to do that?

Upvotes: 0

Views: 173

Answers (1)

steenslag
steenslag

Reputation: 80105

Looks like you want a tmpdir, not a tmpfile.

require 'tmpdir'
puts Dir.mktmpdir('') #the empty string means : no prefix
#=>"/tmp/20120210-9462-kzrkxx"

Upvotes: 1

Related Questions