class Bio::Command::Tmpdir

Bio::Command::Tmpdir is a wrapper class to handle temporary directory like Tempfile class. A temporary directory is created when the object of the class is created, and automatically removed when the object is destroyed by GC.

BioRuby library internal use only.

Public Class Methods

new(prefix_suffix = nil, tmpdir = nil) click to toggle source

Creates a new Tmpdir object. The arguments are the same as Bio::Command.mktmpdir.


Arguments:

  • (optional) prefix_suffix: String (or Array)

  • (optional) tmpdir: String: temporary directory’s path

Returns

Tmpdir object

    # File lib/bio/command.rb
668 def initialize(prefix_suffix = nil, tmpdir = nil)
669   @data = []
670   @clean_proc = Remover.new(@data)
671   ObjectSpace.define_finalizer(self, @clean_proc)
672   @data.push(@path = Bio::Command.mktmpdir(prefix_suffix, tmpdir).freeze)
673 end

Public Instance Methods

close!() click to toggle source

Removes the temporary directory.

Returns

nil

    # File lib/bio/command.rb
685 def close!
686   # raise error if path is nil
687   self.path
688   # finilizer object is called to remove the directory
689   @clean_proc.call
690   # unregister finalizer
691   ObjectSpace.undefine_finalizer(self)
692   # @data and @path is removed
693   @data = @path = nil
694 end
path() click to toggle source

Path to the temporay directory

Returns

String

    # File lib/bio/command.rb
678 def path
679   @path || raise(IOError, 'removed temporary directory')
680 end