Class: Zip::ZipExtraField::UniversalTime
- Defined in:
- lib/zip/zip_extra_field.rb
Overview
Info-ZIP Additional timestamp field
Constant Summary collapse
- HEADER_ID =
"UT"
Instance Attribute Summary collapse
-
#atime ⇒ Object
Returns the value of attribute atime.
-
#ctime ⇒ Object
Returns the value of attribute ctime.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(binstr = nil) ⇒ UniversalTime
constructor
A new instance of UniversalTime.
- #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) ⇒ UniversalTime
Returns a new instance of UniversalTime.
53 54 55 56 57 58 59 |
# File 'lib/zip/zip_extra_field.rb', line 53 def initialize(binstr = nil) @ctime = nil @mtime = nil @atime = nil @flag = nil binstr and merge(binstr) end |
Instance Attribute Details
#atime ⇒ Object
Returns the value of attribute atime.
60 61 62 |
# File 'lib/zip/zip_extra_field.rb', line 60 def atime @atime end |
#ctime ⇒ Object
Returns the value of attribute ctime.
60 61 62 |
# File 'lib/zip/zip_extra_field.rb', line 60 def ctime @ctime end |
#flag ⇒ Object
Returns the value of attribute flag.
60 61 62 |
# File 'lib/zip/zip_extra_field.rb', line 60 def flag @flag end |
#mtime ⇒ Object
Returns the value of attribute mtime.
60 61 62 |
# File 'lib/zip/zip_extra_field.rb', line 60 def mtime @mtime end |
Instance Method Details
#==(other) ⇒ Object
72 73 74 75 76 |
# File 'lib/zip/zip_extra_field.rb', line 72 def ==(other) @mtime == other.mtime && @atime == other.atime && @ctime == other.ctime end |
#merge(binstr) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/zip/zip_extra_field.rb', line 62 def merge(binstr) return if binstr.empty? size, content = initial_parse(binstr) size or return @flag, mtime, atime, ctime = content.unpack("CVVV") mtime and @mtime ||= DOSTime.at(mtime) atime and @atime ||= DOSTime.at(atime) ctime and @ctime ||= DOSTime.at(ctime) end |
#pack_for_c_dir ⇒ Object
86 87 88 89 90 |
# File 'lib/zip/zip_extra_field.rb', line 86 def pack_for_c_dir s = [@flag].pack("C") @flag & 1 == 1 and s << [@mtime.to_i].pack("V") s end |
#pack_for_local ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/zip/zip_extra_field.rb', line 78 def pack_for_local s = [@flag].pack("C") @flag & 1 != 0 and s << [@mtime.to_i].pack("V") @flag & 2 != 0 and s << [@atime.to_i].pack("V") @flag & 4 != 0 and s << [@ctime.to_i].pack("V") s end |