Skip to content

Commit ee028d2

Browse files
committed
UniversalTime: more ruby-like (readable) code.
1 parent d0b4d41 commit ee028d2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/zip/extra_field/universal_time.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def initialize(binstr = nil)
1313
@mtime = nil
1414
@atime = nil
1515
@flag = 0
16-
binstr && merge(binstr)
16+
17+
merge(binstr) unless binstr.nil?
1718
end
1819

1920
attr_reader :atime, :ctime, :mtime, :flag
@@ -58,15 +59,15 @@ def ==(other)
5859

5960
def pack_for_local
6061
s = [@flag].pack('C')
61-
@flag & 1 != 0 && s << [@mtime.to_i].pack('l<')
62-
@flag & 2 != 0 && s << [@atime.to_i].pack('l<')
63-
@flag & 4 != 0 && s << [@ctime.to_i].pack('l<')
62+
s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0
63+
s << [@atime.to_i].pack('l<') unless @flag & ATIME_MASK == 0
64+
s << [@ctime.to_i].pack('l<') unless @flag & CTIME_MASK == 0
6465
s
6566
end
6667

6768
def pack_for_c_dir
6869
s = [@flag].pack('C')
69-
@flag & 1 == 1 && s << [@mtime.to_i].pack('l<')
70+
s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0
7071
s
7172
end
7273
end

0 commit comments

Comments
 (0)