class BinData::Buffer

multiple fields are required.
:type
The single type inside the buffer. Use a struct if
:length

The number of bytes in the buffer.
an object. These params are:
Parameters may be provided at initialisation to control the behaviour of
== Parameters
end
end
end
string :str, length: :len
uint8 :len
array read_until: :eof do
buffer :strings, length: :table_size_in_bytes do
uint16 :table_size_in_bytes
endian :little
class StringTable < BinData::Record
obj.num_bytes #=> 8
obj.raw_num_bytes #=> 4
obj.num1 #=> 2
obj.num1 #=> 1
obj = MyBuffer.read(“001000002000000000000000”)
end
# padding occurs here
uint16 :num2
uint16 :num1
endian :little
default_parameter length: 8
class MyBuffer < BinData::Buffer
obj.to_binary_s #=> “abc000000”
obj = BinData::Buffer.new(length: 5, type: [:string, {value: “abc”}])
require ‘bindata’
will pad the substream with “0” bytes.
fill the buffer. Short reads will skip over unused bytes and short writes
defined size and it will always read or write the exact number of bytes to
A Buffer is conceptually a substream within a data stream. It has a

def assign(val)

def assign(val)
  @type.assign(val)
end

def clear?

def clear?
  @type.clear?
end

def do_num_bytes # :nodoc:

:nodoc:
def do_num_bytes # :nodoc:
  eval_parameter(:length)
end

def do_read(io) # :nodoc:

:nodoc:
def do_read(io) # :nodoc:
  buf_len = eval_parameter(:length)
  io.transform(BufferIO.new(buf_len)) do |transformed_io, _|
    @type.do_read(transformed_io)
  end
end

def do_write(io) # :nodoc:

:nodoc:
def do_write(io) # :nodoc:
  buf_len = eval_parameter(:length)
  io.transform(BufferIO.new(buf_len)) do |transformed_io, _|
    @type.do_write(transformed_io)
  end
end

def initialize_instance

def initialize_instance
  @type = get_parameter(:type).instantiate(nil, self)
end

def method_missing(symbol, *args, &block) # :nodoc:

:nodoc:
def method_missing(symbol, *args, &block) # :nodoc:
  @type.__send__(symbol, *args, &block)
end

def raw_num_bytes

The number of bytes used, ignoring the padding imposed by the buffer.
def raw_num_bytes
  @type.num_bytes
end

def respond_to_missing?(symbol, include_all = false) # :nodoc:

:nodoc:
def respond_to_missing?(symbol, include_all = false) # :nodoc:
  @type.respond_to?(symbol, include_all) || super
end

def snapshot

def snapshot
  @type.snapshot
end