8000 UniversalTime: more ruby-like (readable) code. · rubyzip/rubyzip@ee0a718 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee0a718

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

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
@@ -9,7 +9,8 @@ def initialize(binstr = nil)
99
@mtime = nil
1010
@atime = nil
1111
@flag = 0
12-
binstr && merge(binstr)
12+
13+
merge(binstr) unless binstr.nil?
1314
end
1415

1516
attr_reader :atime, :ctime, :mtime, :flag
@@ -63,15 +64,15 @@ def ==(other)
6364

6465
def pack_for_local
6566
s = [@flag].pack('C')
66-
@flag & 1 != 0 && s << [@mtime.to_i].pack('l<')
67-
@flag & 2 != 0 && s << [@atime.to_i].pack('l<')
68-
@flag & 4 != 0 && s << [@ctime.to_i].pack('l<')
67+
s << [@mtime.to_i].pack('l<') unless @flag & 1 == 0
68+
s << [@atime.to_i].pack('l<') unless @flag & 2 == 0
69+
s << [@ctime.to_i].pack('l<') unless @flag & 4 == 0
6970
s
7071
end
7172

7273
def pack_for_c_dir
7374
s = [@flag].pack('C')
74-
@flag & 1 == 1 && s << [@mtime.to_i].pack('l<')
75+
s << [@mtime.to_i].pack('l<') unless @flag & 1 == 0
7576
s
7677
end
7778
end

0 commit comments

Comments
 (0)
0