class Archive::Zip::ExtraField::Raw
Archive::Zip::Entry::ExtraField::Raw represents an unknown extra field. It is used to store extra fields the Archive::Zip
library does not directly support.
Do not use this class directly. Define a new class which supports the extra field of interest directly instead.
Attributes
Returns the data contained within this ExtraField
.
Returns the header ID for this ExtraField
.
Public Class Methods
Simply stores header_id and data for later reproduction by dump_central
or dump_local
. central_record indicates that this field resides in the central file record for an entry when true
. When false
, it indicates that this field resides in the local file record for an entry.
# File lib/archive/zip/extra_field/raw.rb, line 32 def initialize(header_id, data, central_record) @header_id = header_id @central_record_data = [] @local_record_data = [] if central_record then @central_record_data << data else @local_record_data << data end end
Simply stores header_id and data for later reproduction by dump_central
. This is essentially and alias for new.
# File lib/archive/zip/extra_field/raw.rb, line 15 def parse_central(header_id, data) new(header_id, data, true) end
Simply stores header_id and data for later reproduction by dump_local
. This is essentially and alias for new.
# File lib/archive/zip/extra_field/raw.rb, line 22 def parse_local(header_id, data) new(header_id, data, false) end
Public Instance Methods
This method signature is part of the interface contract expected by Archive::Zip::Entry
for extra field objects.
Returns a String suitable to writing to a central file record in a ZIP archive file which contains the data for this object.
# File lib/archive/zip/extra_field/raw.rb, line 73 def dump_central @central_record_data.collect do |data| [header_id, data.size].pack('vv') + data end end
This method signature is part of the interface contract expected by Archive::Zip::Entry
for extra field objects.
Returns a String suitable to writing to a local file record in a ZIP archive file which contains the data for this object.
# File lib/archive/zip/extra_field/raw.rb, line 84 def dump_local @local_record_data.collect do |data| [header_id, data.size].pack('vv') + data end end
This method signature is part of the interface contract expected by Archive::Zip::Entry
for extra field objects.
Merges the attributes of other into this object and returns self
.
Raises ArgumentError if other does not have the same header ID as this object.
# File lib/archive/zip/extra_field/raw.rb, line 56 def merge(other) if header_id != other.header_id then raise ArgumentError, "Header ID mismatch: #{header_id} != #{other.header_id}" end @central_record_data += other.central_record_data @local_record_data += other.local_record_data self end