Class: BinData::Uint8Array
- Inherits:
-
BasePrimitive
- Object
- BasePrimitive
- BinData::Uint8Array
- Defined in:
- lib/bindata/uint8_array.rb
Overview
Uint8Array is a specialised type of array that only contains
bytes (Uint8). It is a faster and more memory efficient version
of BinData::Array.new(:type => :uint8).
require 'bindata'
obj = BinData::Uint8Array.new(initial_length: 5)
obj.read("abcdefg") #=> [97, 98, 99, 100, 101]
obj[2] #=> 99
obj.collect { |x| x.chr }.join #=> "abcde"
Parameters
Parameters may be provided at initialisation to control the behaviour of an object. These params are:
:initial_length:: The initial length of the array.
:read_until:: May only have a value of :eof. This parameter
instructs the array to read as much data from
the stream as possible.