Class: Zip::ZipExtraField::UniversalTime
- Defined in:
- lib/ruby_archive/handlers/rubyzip/zip/zip.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.
1717 1718 1719 1720 1721 1722 1723 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1717 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.
1724 1725 1726 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1724 def atime @atime end |
#ctime ⇒ Object
Returns the value of attribute ctime.
1724 1725 1726 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1724 def ctime @ctime end |
#flag ⇒ Object
Returns the value of attribute flag.
1724 1725 1726 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1724 def flag @flag end |
#mtime ⇒ Object
Returns the value of attribute mtime.
1724 1725 1726 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1724 def mtime @mtime end |
Instance Method Details
#==(other) ⇒ Object
1736 1737 1738 1739 1740 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1736 def ==(other) @mtime == other.mtime && @atime == other.atime && @ctime == other.ctime end |
#merge(binstr) ⇒ Object
1726 1727 1728 1729 1730 1731 1732 1733 1734 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1726 def merge(binstr) binstr == "" and return size, content = initial_parse(binstr) size or return @flag, mtime, atime, ctime = content.unpack("CVVV") mtime and @mtime ||= Time.at(mtime) atime and @atime ||= Time.at(atime) ctime and @ctime ||= Time.at(ctime) end |
#pack_for_c_dir ⇒ Object
1750 1751 1752 1753 1754 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1750 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
1742 1743 1744 1745 1746 1747 1748 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1742 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 |