method

tmpdir

v2_5_5 - Show latest stable - Class: Dir
tmpdir()
public

Returns the operating system’s temporary file path.

1Note

Don't forget to require 'tmpdir'

mcmire · Oct 31, 20092 thanks

If you simply say Dir.tmpdir you might get a nice surprise:

irb> Dir.tmpdir NoMethodError: undefined method `tmpdir' for Dir:Class from (irb):1

Strangely, this method seems to be stored in a file that Ruby doesn't require by default. Just require 'tmpdir' and all should be well.

irb> require 'tmpdir' => true irb> Dir.tmpdir => "/var/folders/An/AnwlXPZFH2aRLCERERQDKE+++TI/-Tmp-"