Class: Renalware::ZipArchive

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/zip_archive.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ ZipArchive

Returns a new instance of ZipArchive.



7
8
9
# File 'app/models/renalware/zip_archive.rb', line 7

def initialize(file)
  @file = Pathname.new(file)
end

Instance Method Details

#rar_archive?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/renalware/zip_archive.rb', line 20

def rar_archive?
  `file #{file}`.match? /RAR/
end

#unzipObject



11
12
13
14
15
16
17
18
# File 'app/models/renalware/zip_archive.rb', line 11

def unzip
  # Create a tmp dir and ensure PG has access to it.
  Dir.mktmpdir do |dir|
    `chmod a+rX #{dir}`
    files = unzip_to_tmp_dir_and_return_pathames_array(dir)
    yield(files)
  end
end