Class: Zip::ExtraField::IUnix
- Defined in:
- lib/zip/extra_field/unix.rb
Overview
Info-ZIP Extra for UNIX uid/gid
Constant Summary collapse
- HEADER_ID =
'Ux'
Instance Attribute Summary collapse
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(binstr = nil) ⇒ IUnix
constructor
A new instance of IUnix.
- #merge(binstr) ⇒ Object
- #pack_for_c_dir ⇒ Object
- #pack_for_local ⇒ Object
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.
7 8 9 10 11 |
# File 'lib/zip/extra_field/unix.rb', line 7 def initialize(binstr = nil) @uid = 0 @gid = 0 binstr && merge(binstr) end |
Instance Attribute Details
#gid ⇒ Object
Returns the value of attribute gid.
13 14 15 |
# File 'lib/zip/extra_field/unix.rb', line 13 def gid @gid end |
#uid ⇒ Object
Returns the value of attribute uid.
13 14 15 |
# File 'lib/zip/extra_field/unix.rb', line 13 def uid @uid end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 |
# File 'lib/zip/extra_field/unix.rb', line 27 def ==(other) @uid == other.uid && @gid == other.gid end |
#merge(binstr) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zip/extra_field/unix.rb', line 15 def merge(binstr) return if binstr.empty? size, content = initial_parse(binstr) # size: 0 for central directory. 4 for local header return if !size || size == 0 uid, gid = content.unpack('vv') @uid ||= uid @gid ||= gid # rubocop:disable Naming/MemoizedInstanceVariableName end |
#pack_for_c_dir ⇒ Object
35 36 37 |
# File 'lib/zip/extra_field/unix.rb', line 35 def pack_for_c_dir '' end |
#pack_for_local ⇒ Object
31 32 33 |
# File 'lib/zip/extra_field/unix.rb', line 31 def pack_for_local [@uid, @gid].pack('vv') end |