Method: Pry::Helpers::CommandHelpers#temp_file

Defined in:
lib/pry/helpers/command_helpers.rb

#temp_file(ext = '.rb') ⇒ String

Open a temp file and yield it to the block, closing it after

Returns:

  • (String)

    The path of the temp file



14
15
16
17
18
19
# File 'lib/pry/helpers/command_helpers.rb', line 14

def temp_file(ext = '.rb')
  file = Tempfile.new(['pry', ext])
  yield(file)
ensure
  file.close(true)
end