Sha256: 2ce982d299658e0af3c829686d9a496c7e3bf4a2388eed79a071b5b6ff4dc908

Contents?: true

Size: 643 Bytes

Versions: 378

Compression:

Stored size: 643 Bytes

Contents

# frozen_string_literal: true

require 'pathname'
require 'tempfile'

module EacRubyUtils
  module Fs
    module Temp
      class File < Pathname
        # Temporary file
        def initialize(*tempfile_args)
          file = Tempfile.new(*tempfile_args)
          path = file.path
          file.close
          file.unlink
          super(path)
        end

        def remove
          if directory?
            rmtree
          elsif file?
            unlink
          end
        end

        def remove!
          remove
          raise "Tried to remove \"#{self}\", but it yet exists" if exist?
        end
      end
    end
  end
end

Version data entries

378 entries across 378 versions & 4 rubygems

Version Path
eac_tools-0.61.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.60.3 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.60.2 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.60.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.60.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.59.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.58.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.57.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.56.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.56.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.7 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.6 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.5 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.4 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.3 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.2 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.112.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.111.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.55.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb