Class: Rant::Archive::Rubyzip::ZipStreamableFile

Inherits:
ZipEntry show all
Defined in:
lib/rant/archive/rubyzip.rb

Overview

:nodoc:all

Constant Summary

Constants inherited from ZipEntry

Rant::Archive::Rubyzip::ZipEntry::CDIR_ENTRY_STATIC_HEADER_LENGTH, Rant::Archive::Rubyzip::ZipEntry::CENTRAL_DIRECTORY_ENTRY_SIGNATURE, Rant::Archive::Rubyzip::ZipEntry::DEFLATED, Rant::Archive::Rubyzip::ZipEntry::LOCAL_ENTRY_SIGNATURE, Rant::Archive::Rubyzip::ZipEntry::LOCAL_ENTRY_STATIC_HEADER_LENGTH, Rant::Archive::Rubyzip::ZipEntry::STORED

Instance Attribute Summary

Attributes inherited from ZipEntry

#comment, #compressed_size, #compression_method, #crc, #externalFileAttributes, #extra, #fstype, #localHeaderOffset, #name, #size, #zipfile

Instance Method Summary collapse

Methods inherited from ZipEntry

#<=>, #cdir_header_size, #directory?, #file?, #get_raw_input_stream, #local_entry_offset, #local_header_size, #next_header_offset, #parent_as_string, #read_c_dir_entry, read_c_dir_entry, #read_local_entry, read_local_entry, #time, #time=, #to_s, #write_c_dir_entry, #write_local_entry

Constructor Details

#initialize(entry, filepath) ⇒ ZipStreamableFile

Returns a new instance of ZipStreamableFile.



1276
1277
1278
1279
1280
# File 'lib/rant/archive/rubyzip.rb', line 1276

def initialize(entry, filepath)
  super(entry)
  @delegate = entry
  @filepath = filepath
end

Instance Method Details

#==(other) ⇒ Object



1291
1292
1293
1294
# File 'lib/rant/archive/rubyzip.rb', line 1291

def == (other)
  return false unless other.class == ZipStreamableFile
  @filepath == other.filepath && super(other.delegate)
end

#get_input_stream(&aProc) ⇒ Object



1282
1283
1284
# File 'lib/rant/archive/rubyzip.rb', line 1282

def get_input_stream(&aProc)
  File.open(@filepath, "rb", &aProc)
end

#write_to_zip_output_stream(aZipOutputStream) ⇒ Object



1286
1287
1288
1289
# File 'lib/rant/archive/rubyzip.rb', line 1286

def write_to_zip_output_stream(aZipOutputStream)
  aZipOutputStream.put_next_entry(self)
  aZipOutputStream << get_input_stream { |is| is.read }
end