Skip to content

Commit

Permalink
UniversalTime: more ruby-like (readable) code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Dec 15, 2019
1 parent d0b4d41 commit ee028d2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/zip/extra_field/universal_time.rb
Expand Up @@ -13,7 +13,8 @@ def initialize(binstr = nil)
@mtime = nil
@atime = nil
@flag = 0
binstr && merge(binstr)

merge(binstr) unless binstr.nil?
end

attr_reader :atime, :ctime, :mtime, :flag
Expand Down Expand Up @@ -58,15 +59,15 @@ def ==(other)

def pack_for_local
s = [@flag].pack('C')
@flag & 1 != 0 && s << [@mtime.to_i].pack('l<')
@flag & 2 != 0 && s << [@atime.to_i].pack('l<')
@flag & 4 != 0 && s << [@ctime.to_i].pack('l<')
s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0
s << [@atime.to_i].pack('l<') unless @flag & ATIME_MASK == 0
s << [@ctime.to_i].pack('l<') unless @flag & CTIME_MASK == 0
s
end

def pack_for_c_dir
s = [@flag].pack('C')
@flag & 1 == 1 && s << [@mtime.to_i].pack('l<')
s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0
s
end
end
Expand Down

0 comments on commit ee028d2

Please sign in to comment.