Class: BinData::Uint8Array

Inherits:
BasePrimitive show all
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.

Instance Attribute Summary

Attributes inherited from Base

#parent

Method Summary

Methods inherited from BasePrimitive

#<=>, #assign, bit_aligned, #clear?, #do_num_bytes, #do_read, #do_read_with_hook, #do_write, #eql?, #hash, #initialize_instance, #initialize_shared_instance, #method_missing, #respond_to_missing?, #snapshot, #value, #value=

Methods included from TraceHook

#turn_off_tracing, #turn_on_tracing

Methods inherited from Base

#==, #=~, #abs_offset, arg_processor, auto_call_delayed_io, bindata_name, #clear, #debug_name, #eval_parameter, #get_parameter, #has_parameter?, #initialize_instance, #initialize_with_warning, #inspect, #lazy_evaluator, #new, #num_bytes, #pretty_print, #read, read, register_subclasses, #rel_offset, #safe_respond_to?, #to_binary_s, #to_hex, #to_s, unregister_self, #write

Methods included from AcceptedParametersPlugin

#accepted_parameters, #default_parameters, #mandatory_parameters, #mutually_exclusive_parameters, #optional_parameters

Methods included from RegisterNamePlugin

included, #initialize_shared_instance

Methods included from Framework

#assign, #bit_aligned?, #clear?, #debug_name_of, #offset_of, #snapshot

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BinData::BasePrimitive