Module: Ronin::Payloads::Mixins::Tempfile

Defined in:
lib/ronin/payloads/mixins/tempfile.rb

Overview

Adds support for temporary files.

Instance Method Summary collapse

Instance Method Details

#tempfile(name = nil, ext: nil) {|tempfile| ... } ⇒ Tempfile

Opens a new temporary file.

Parameters:

  • name (String, nil) (defaults to: nil)

    The optional name for the temporary file.

  • ext (String, ext) (defaults to: nil)

    The optional file extension to add to the temporary file.

Yields:

  • (tempfile)

    If a block is given it will be passed the newly opened temporary file. Once the block returns the temp file will be closed.

Yield Parameters:

  • tempfile (Tempfile)

    The newly created temporary file.

Returns:

  • (Tempfile)

    The newly created temporary file.

See Also:



54
55
56
57
58
59
60
# File 'lib/ronin/payloads/mixins/tempfile.rb', line 54

def tempfile(name=nil, ext: nil,&block)
  basename = if name then "ronin-payloads-#{name}-"
             else         'ronin-payloads-'
             end

  ::Tempfile.open([basename, ext],&block)
end