Class: Zip::ZipExtraField::IUnix

Inherits:
Generic show all
Defined in:
lib/zip/zip.rb

Overview

Info-ZIP Extra for UNIX uid/gid

Constant Summary collapse

HEADER_ID =
"Ux"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Generic

#initial_parse, name, register_map, #to_c_dir_bin, #to_local_bin

Constructor Details

#initialize(binstr = nil) ⇒ IUnix

Returns a new instance of IUnix.



1260
1261
1262
1263
1264
# File 'lib/zip/zip.rb', line 1260

def initialize(binstr = nil)
  @uid = nil
  @gid = nil
  binstr and merge(binstr)
end

Instance Attribute Details

#gidObject

Returns the value of attribute gid.



1265
1266
1267
# File 'lib/zip/zip.rb', line 1265

def gid
  @gid
end

#uidObject

Returns the value of attribute uid.



1265
1266
1267
# File 'lib/zip/zip.rb', line 1265

def uid
  @uid
end

Instance Method Details

#==(other) ⇒ Object



1277
1278
1279
1280
# File 'lib/zip/zip.rb', line 1277

def ==(other)
  @uid == other.uid &&
  @gid == other.gid
end

#merge(binstr) ⇒ Object



1267
1268
1269
1270
1271
1272
1273
1274
1275
# File 'lib/zip/zip.rb', line 1267

def merge(binstr)
  binstr == "" and return
  size, content = initial_parse(binstr)
  # size: 0 for central direcotry. 4 for local header
  return if(! size || size == 0)
  uid, gid = content.unpack("vv")
  @uid ||= uid
  @gid ||= gid
end

#pack_for_c_dirObject



1286
1287
1288
# File 'lib/zip/zip.rb', line 1286

def pack_for_c_dir
  ""
end

#pack_for_localObject



1282
1283
1284
# File 'lib/zip/zip.rb', line 1282

def pack_for_local
  [@uid, @gid].pack("vv")
end