examples/gzip.rb in bindata-0.9.3 vs examples/gzip.rb in bindata-0.10.0
- old
+ new
@@ -7,18 +7,18 @@
extend Forwardable
# Known compression methods
DEFLATE = 8
- class Extra < BinData::MultiValue
+ class Extra < BinData::Record
endian :little
uint16 :len, :length => lambda { data.length }
string :data, :read_length => :len
end
- class Header < BinData::MultiValue
+ class Header < BinData::Record
endian :little
uint16 :ident, :value => 0x8b1f, :check_value => 0x8b1f
uint8 :compression_method, :initial_value => DEFLATE
@@ -43,11 +43,11 @@
stringz :file_name, :onlyif => lambda { ffile_name.nonzero? }
stringz :comment, :onlyif => lambda { fcomment.nonzero? }
uint16 :crc16, :onlyif => lambda { fcrc16.nonzero? }
end
- class Footer < BinData::MultiValue
+ class Footer < BinData::Record
endian :little
uint32 :crc32
uint32 :uncompressed_size
end
@@ -62,10 +62,10 @@
def_delegators :@header, :comment=, :comment
def_delegators :@header, :compression_method
def_delegators :@footer, :crc32, :uncompressed_size
def mtime
- Time.at(@header.mtime)
+ Time.at(@header.mtime.snapshot)
end
def mtime=(tm)
@header.mtime = tm.to_i
end