Class: Glark::ZipFile

Inherits:
ArchiveFile show all
Includes:
Loggable
Defined in:
lib/glark/io/file/zip_file.rb

Instance Method Summary collapse

Methods inherited from ArchiveFile

#each, #list, #search, #search_archive_file, #search_list

Constructor Details

#initialize(fname, range, &blk) ⇒ ZipFile

Returns a new instance of ZipFile.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/glark/io/file/zip_file.rb', line 10

def initialize fname, range, &blk
  super fname, range
  
  # Same caveat as ZipFile. Given that this is a gem, I'm not sure if it is
  # installed with other package managers. So the require is down here, used
  # only if needed.

  begin
    require 'zip/zip'
  rescue LoadError => e
    msg = "error loading zip gem: #{e}\n"
    msg << "to install this dependency, run 'gem install rubyzip'"
    info "msg: #{msg}".color(:red)
    raise msg
  end
end

Instance Method Details

#entry_name(entry) ⇒ Object



35
36
37
# File 'lib/glark/io/file/zip_file.rb', line 35

def entry_name entry
  entry.name
end

#get_readerObject



27
28
29
# File 'lib/glark/io/file/zip_file.rb', line 27

def get_reader 
  @zipfile = Zip::ZipFile.new @fname
end

#read(entry) ⇒ Object



31
32
33
# File 'lib/glark/io/file/zip_file.rb', line 31

def read entry
  @zipfile.read entry
end