open

open(*args)
Class Public methods

Creates a new Tempfile.

If no block is given, this is a synonym for ::new.

If a block is given, then a Tempfile object will be constructed, and the block is run with said object as argument. The Tempfile object will be automatically closed after the block terminates. The call returns the value of the block.

In any case, all arguments (+*args+) will be passed to ::new.

Tempfile.open('foo', '/home/temp') do |f|
   ... do something with f ...
end

# Equivalent:
f = Tempfile.open('foo', '/home/temp')
begin
   ... do something with f ...
ensure
   f.close
end
doc_ruby_on_rails
2015-05-17 07:40:57
Comments
Leave a Comment

Please login to continue.