Class: Glark::TarFile

Inherits:
ArchiveFile show all
Defined in:
lib/glark/io/file/tar_file.rb

Instance Method Summary collapse

Methods inherited from ArchiveFile

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

Constructor Details

#initialize(fname, range, io = nil, &blk) ⇒ TarFile

Returns a new instance of TarFile.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/glark/io/file/tar_file.rb', line 9

def initialize fname, range, io = nil, &blk
  super fname, range

  # 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.
  
  # module Gem::Package is declared in 'rubygems/package', not in
  # .../tar_reader.
  require 'rubygems/package'
  require 'rubygems/package/tar_reader'
  @io = io
end

Instance Method Details

#entry_name(entry) ⇒ Object



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

def entry_name entry
  entry.full_name
end

#get_readerObject



22
23
24
25
# File 'lib/glark/io/file/tar_file.rb', line 22

def get_reader 
  io = @io || ::File.new(@fname)
  Gem::Package::TarReader.new io
end

#read(entry) ⇒ Object



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

def read entry
  entry.read
end