Class: Zip::ZipExtraField::Generic

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

Overview

Meta class for extra fields

Direct Known Subclasses

IUnix, UniversalTime

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nameObject


1175
1176
1177
# File 'lib/zip/zip.rb', line 1175

def self.name
  self.to_s.split("::")[-1]
end

.register_mapObject


1169
1170
1171
1172
1173
# File 'lib/zip/zip.rb', line 1169

def self.register_map
  if self.const_defined?(:HEADER_ID)
    ID_MAP[self.const_get(:HEADER_ID)] = self
  end
end

Instance Method Details

#==(other) ⇒ Object


1191
1192
1193
1194
1195
1196
1197
# File 'lib/zip/zip.rb', line 1191

def ==(other)
  self.class != other.class and return false
  each { |k, v|
    v != other[k] and return false
  }
  true
end

#initial_parse(binstr) ⇒ Object

return field [size, content] or false


1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
# File 'lib/zip/zip.rb', line 1180

def initial_parse(binstr)
  if ! binstr
    # If nil, start with empty.
    return false
  elsif binstr[0,2] != self.class.const_get(:HEADER_ID)
    $stderr.puts "Warning: weired extra feild header ID. skip parsing"
    return false
  end
  [binstr[2,2].unpack("v")[0], binstr[4..-1]]
end

#to_c_dir_binObject


1204
1205
1206
1207
# File 'lib/zip/zip.rb', line 1204

def to_c_dir_bin
  s = pack_for_c_dir
  self.class.const_get(:HEADER_ID) + [s.length].pack("v") + s
end

#to_local_binObject


1199
1200
1201
1202
# File 'lib/zip/zip.rb', line 1199

def to_local_bin
  s = pack_for_local
  self.class.const_get(:HEADER_ID) + [s.length].pack("v") + s
end