class Zip::ExtraField::UniversalTime

Info-ZIP Additional timestamp field

Constants

HEADER_ID

Attributes

atime[RW]
ctime[RW]
flag[RW]
mtime[RW]

Public Class Methods

new(binstr = nil) click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 7
def initialize(binstr = nil)
  @ctime = nil
  @mtime = nil
  @atime = nil
  @flag  = nil
  binstr && merge(binstr)
end

Public Instance Methods

==(other) click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 27
def ==(other)
  @mtime == other.mtime &&
    @atime == other.atime &&
    @ctime == other.ctime
end
merge(binstr) click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 17
def merge(binstr)
  return if binstr.empty?
  size, content = initial_parse(binstr)
  size || return
  @flag, mtime, atime, ctime = content.unpack('CVVV')
  mtime && @mtime ||= ::Zip::DOSTime.at(mtime)
  atime && @atime ||= ::Zip::DOSTime.at(atime)
  ctime && @ctime ||= ::Zip::DOSTime.at(ctime)
end
pack_for_c_dir() click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 41
def pack_for_c_dir
  s = [@flag].pack('C')
  @flag & 1 == 1 && s << [@mtime.to_i].pack('V')
  s
end
pack_for_local() click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 33
def pack_for_local
  s = [@flag].pack('C')
  @flag & 1 != 0 && s << [@mtime.to_i].pack('V')
  @flag & 2 != 0 && s << [@atime.to_i].pack('V')
  @flag & 4 != 0 && s << [@ctime.to_i].pack('V')
  s
end