Class Bio::Command::Tmpdir
In: lib/bio/command.rb
Parent: Object

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.

Methods

close!   new   path  

Classes and Modules

Class Bio::Command::Tmpdir::Remover

Public Class methods

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

[Source]

     # File lib/bio/command.rb, line 668
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

Removes the temporary directory.

Returns:nil

[Source]

     # File lib/bio/command.rb, line 685
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 to the temporay directory

Returns:String

[Source]

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

[Validate]