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_ruby_utils-0.124.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.97.2 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.123.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.121.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.120.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.76.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.76.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.75.2 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.119.2 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.75.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.75.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.119.1 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.74.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.74.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.73.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.119.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.72.0 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.118.1 lib/eac_ruby_utils/fs/temp/file.rb
eac_ruby_utils-0.118.0 lib/eac_ruby_utils/fs/temp/file.rb
eac_tools-0.70.1 sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb