lib/rstruct/base_types/packed_type.rb
def read(raw, predecessors=nil)
        if raw.respond_to?(:read)
          raw = raw.read(self.sizeof())
        end
        if raw.size < self.sizeof()
          raise(ReadError, "Expected #{self.sizeof} bytes, but only got #{raw.size} bytes")
        end

        vals = 
          if @unpack_cb
            @unpack_cb.call(raw, predecessors)
          else
            raw.unpack(self.format)
          end
        return(self.claim_value(vals, predecessors))
      end
def read(raw, predecessors=nil)
        if raw.respond_to?(:read)
          raw = raw.read(self.sizeof())
        end
        if raw.size < self.sizeof()
          raise(ReadError, "Expected #{self.sizeof} bytes, but only got #{raw.size} bytes")
        end

        vals = 
          if @unpack_cb
            @unpack_cb.call(raw, predecessors)
          else
            raw.unpack(self.format)
          end
        return(self.claim_value(vals, predecessors))
      end
Called when parsing. While you can override this in subclasses,
 in general it is probably better to use the 'on_unpack' method
 to define a proc to handle unpacking for special cases.