Class: Zippo::IOZipMember

Inherits:
Object
  • Object
show all
Defined in:
lib/zippo/io_zip_member.rb

Overview

A zip member sourced from an IO object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source) ⇒ IOZipMember

Returns a new instance of IOZipMember.



9
10
11
12
# File 'lib/zippo/io_zip_member.rb', line 9

def initialize(name, source)
  @name = name
  @source = source
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/zippo/io_zip_member.rb', line 7

def name
  @name
end

Instance Method Details

#readObject



14
15
16
17
18
# File 'lib/zippo/io_zip_member.rb', line 14

def read
  @source.read
ensure
  @source.rewind
end

#write_to(out, preferred_compression_method = Filter::DeflateCompressor::METHOD, _recompress = nil) ⇒ Object



20
21
22
# File 'lib/zippo/io_zip_member.rb', line 20

def write_to(out, preferred_compression_method = Filter::DeflateCompressor::METHOD, _recompress = nil)
  Filter::Compressor.for(preferred_compression_method).new(@source).compress_to(out)
end