Skip to content

Instantly share code, notes, and snippets.

@iwazer
Created May 27, 2011 05:55
Show Gist options
  • Save iwazer/994722 to your computer and use it in GitHub Desktop.
Save iwazer/994722 to your computer and use it in GitHub Desktop.
Rubyで拡張子を指定して一時ファイルを生成する
require 'tempfile'
Dir.mkdir('tmp') unless FileTest.exist?('tmp')
tempfile = Tempfile.new(['xx', '.txt'], 'tmp')
puts tempfile.path
# => /Users/iwazawa/tmp/xx20110527-4157-1cev5di.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment