Class: Giff::Tarball

Inherits:
Object
  • Object
show all
Defined in:
lib/giff/tarball.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, gz: false) ⇒ Tarball

Returns a new instance of Tarball.



5
6
7
8
9
10
11
12
13
# File 'lib/giff/tarball.rb', line 5

def initialize(io, gz: false)
  io = Zlib::GzipReader.new(io) if gz

  @contents = Hash[
    Archive::Tar::Minitar::Input.each_entry(io).map do |e|
      [e.name, e.read]
    end
  ]
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



15
16
17
# File 'lib/giff/tarball.rb', line 15

def contents
  @contents
end

Instance Method Details

#read(filename) ⇒ Object



17
18
19
# File 'lib/giff/tarball.rb', line 17

def read(filename)
  contents.fetch(filename)
end