lib/bindata/buffer.rb in bindata-2.3.2 vs lib/bindata/buffer.rb in bindata-2.3.3

- old
+ new

@@ -24,10 +24,11 @@ # end # # obj = MyBuffer.read("\001\000\002\000\000\000\000\000") # obj.num1 #=> 1 # obj.num1 #=> 2 + # obj.raw_num_bytes #=> 4 # obj.num_bytes #=> 8 # # # class StringTable < BinData::Record # endian :little @@ -58,9 +59,14 @@ mandatory_parameters :length, :type def initialize_instance @type = get_parameter(:type).instantiate(nil, self) + end + + # The number of bytes used, ignoring the padding imposed by the buffer. + def raw_num_bytes + @type.num_bytes end def clear? @type.clear? end