Class: Zip::ZipExtraField

### Home Classes Methods

### In Files

- lib/zip/zip_extra_field.rb

### Parent

Hash

### Namespace

- CLASS Zip::ZipExtraField::Generic
- CLASS Zip::ZipExtraField::IUnix
- CLASS Zip::ZipExtraField::UniversalTime

### Methods

- ::new
- #c_dir_length
- #c_dir_size
- #create
- #length
- #local_length
- #local_size
- #merge
- #size
- #to_c_dir_bin
- #to_local_bin
- #to_s

### Class/Module Index

Quicksearch

- Zip
- Zip::ZipCentralDirectory
- Zip::ZipCompressionMethodError
- Zip::ZipDestinationFileExistsError
- Zip::ZipEntry
- Zip::ZipEntryExistsError
- Zip::ZipEntryNameError
- Zip::ZipError
- Zip::ZipExtraField
- Zip::ZipExtraField::Generic
- Zip::ZipExtraField::IUnix
- Zip::ZipExtraField::UniversalTime
- Zip::ZipFile
- Zip::ZipFileSystem
- Zip::ZipFileSystem::ZipFsDir
- Zip::ZipFileSystem::ZipFsFile
- Zip::ZipFileSystem::ZipFsFile::ZipFsStat
- Zip::ZipInputStream
- Zip::ZipInternalError
- Zip::ZipOutputStream
- Zip::ZipStreamableDirectory
- Zip::ZipStreamableStream
- IOExtras
- IOExtras::AbstractInputStream
- IOExtras::AbstractOutputStream
- IOExtras::FakeIO
- BugFix
- Object

No matching classes.

# Zip::ZipExtraField

### Constants

ID_MAP

### Public Class Methods

new(binstr = nil) click to toggle source

start main of ZipExtraField < Hash

    # File lib/zip/zip_extra_field.rb, line 130
    def initialize(binstr = nil)
      binstr and merge(binstr)
    end

### Public Instance Methods

c_dir_length() click to toggle source

    # File lib/zip/zip_extra_field.rb, line 198
    def c_dir_length
      to_c_dir_bin.bytesize
    end

Also aliased as: c_dir_size
c_dir_size() click to toggle source
Alias for: c_dir_length
create(name) click to toggle source

    # File lib/zip/zip_extra_field.rb, line 167
    def create(name)
      field_class = nil
      ID_MAP.each { |id, klass|
        if klass.name == name
          field_class = klass
          break
        end
      }
      if ! field_class
        raise ZipError, "Unknown extra field '#{name}'"
      end
      self[name] = field_class.new()
    end

length() click to toggle source
Alias for: local_length
local_length() click to toggle source

    # File lib/zip/zip_extra_field.rb, line 201
    def local_length
      to_local_bin.bytesize
    end

Also aliased as: local_size, length, size
local_size() click to toggle source
Alias for: local_length
merge(binstr) click to toggle source

    # File lib/zip/zip_extra_field.rb, line 134
    def merge(binstr)
      return if binstr.empty?
      i = 0
      while i < binstr.bytesize
        id = binstr[i,2]
        len = binstr[i + 2,2].to_s.unpack("v")[0]
        if id && ID_MAP.member?(id)
          field_name = ID_MAP[id].name
          if self.member?(field_name)
            self[field_name].mergea(binstr[i, len + 4])
          else
            field_obj = ID_MAP[id].new(binstr[i, len + 4])
            self[field_name] = field_obj
          end
        elsif id
          unless self["Unknown"]
            s = ""
            class << s
              alias_method :to_c_dir_bin, :to_s
              alias_method :to_local_bin, :to_s
            end
            self["Unknown"] = s
          end
          if !len || len + 4 > binstr[i..-1].bytesize
            self["Unknown"] << binstr[i..-1]
            break
          end
          self["Unknown"] << binstr[i, len + 4]
        end
        i += len + 4
      end
    end

size() click to toggle source
Alias for: local_length
to_c_dir_bin() click to toggle source

    # File lib/zip/zip_extra_field.rb, line 190
    def to_c_dir_bin
      s = ""
      each do |k, v|
        s << v.to_c_dir_bin
      end
      s
    end

to_local_bin() click to toggle source

    # File lib/zip/zip_extra_field.rb, line 181
    def to_local_bin
      s = ""
      each do |k, v|
        s << v.to_local_bin
      end
      s
    end

Also aliased as: to_s
to_s() click to toggle source
Alias for: to_local_bin

[Validate]

Generated with the Darkfish Rdoc Generator 2.