class Bytepack::Hash
Public Class Methods
pack(hash = {})
click to toggle source
# File lib/bytepack/complex/hash.rb, line 5 def pack(hash = {}) AnyType.pack(hash.keys) + AnyType.pack(hash.values) end
unpack(bytes, offset = 0)
click to toggle source
# File lib/bytepack/complex/hash.rb, line 9 def unpack(bytes, offset = 0) keys, offset = *AnyType.unpack(bytes, offset) values, offset = *AnyType.unpack(bytes, offset) [::Hash[keys.map.with_index {|key, index| [key, values[index]]}], offset] end