Class: LibBin::Structure::UInt8

Inherits:
Scalar
  • Object
show all
Defined in:
lib/libbin/data_types.rb

Overview

An unsigned 8 bit integer

Scalars collapse

Methods inherited from Scalar

always_align

Class Method Details

.alignInteger

Returns the alignment of LibBin::Structure::UInt8.

Returns:

  • (Integer)

    the byte boundary to align the type to.



# File 'lib/libbin/data_types.rb', line 3

.convert(input, output, input_big = LibBin::default_big?, output_big = !input_big, parent = nil, index = nil, length = nil) ⇒ Numeric+

Convert a field of class LibBin::Structure::UInt8 by loading it from input and dumping it to output. Returns the loaded field.

Parameters:

  • input (IO)

    the stream to load the field from.

  • output (IO)

    the stream to dump the field to.

  • input_big (Boolean) (defaults to: LibBin::default_big?)

    the endianness of input

  • output_big (Boolean) (defaults to: !input_big)

    the endianness of output.

  • parent (Structure) (defaults to: nil)

    ignored.

  • index (Integer) (defaults to: nil)

    ignored.

  • length (Integer) (defaults to: nil)

    if given the length of the vector. Else the length is considered to be 1.

Returns:

  • (Numeric, Array<Numeric>)

    the Ruby representation of the type, or the Array representation of the vector if length was specified



# File 'lib/libbin/data_types.rb', line 3

.dump(value, output, output_big = LibBin::default_big?, parent = nil, index = nil, length = nil) ⇒ nil

Dump a field of class LibBin::Structure::UInt8 to output.

Parameters:

  • value (Numeric, Array<Numeric>)

    the Ruby representation of the type, or the Array representation of the vector if length is specified.

  • output (IO)

    the stream to dump the field to.

  • output_big (Boolean) (defaults to: LibBin::default_big?)

    the endianness of output.

  • parent (Structure) (defaults to: nil)

    ignored.

  • index (Integer) (defaults to: nil)

    ignored.

  • length (Integer) (defaults to: nil)

    if given the length of the vector. Else the length is considered to be 1.

Returns:

  • (nil)


# File 'lib/libbin/data_types.rb', line 3

.load(input, input_big = LibBin::default_big?, parent = nil, index = nil, length = nil) ⇒ Numeric+

Load a field of type LibBin::Structure::UInt8 from input, and return it.

Parameters:

  • input (IO)

    the stream to load the field from.

  • input_big (Boolean) (defaults to: LibBin::default_big?)

    the endianness of input

  • parent (Structure) (defaults to: nil)

    ignored.

  • index (Integer) (defaults to: nil)

    ignored.

  • length (Integer) (defaults to: nil)

    if given the length of the vector. Else the length is considered to be 1.

Returns:

  • (Numeric, Array<Numeric>)

    the Ruby representation of the type, or the Array representation of the vector if length was specified



# File 'lib/libbin/data_types.rb', line 3

.shape(value = nil, offset = 0, parent = nil, index = nil, kind = DataShape, length = nil) ⇒ kind

Returns the shape of a field of type LibBin::Structure::UInt8

Parameters:

  • value (Object) (defaults to: nil)

    ignored.

  • offset (Integer) (defaults to: 0)

    start of the shape.

  • parent (Structure) (defaults to: nil)

    ignored.

  • index (Integer) (defaults to: nil)

    ignored.

  • kind (Class) (defaults to: DataShape)

    shape class. Will be instantiated through new with the offset and offset + sizeof(uint8_t) * length - 1.

  • length (Integer) (defaults to: nil)

    if given the length of the vector. Else the length is considered to be 1.

Returns:

  • (kind)

    a new instance of kind



# File 'lib/libbin/data_types.rb', line 3

.size(value = nil, offset = 0, parent = nil, index = nil, length = nil) ⇒ Integer

Returns the size of a field of type LibBin::Structure::UInt8.

Parameters:

  • value (Object) (defaults to: nil)

    ignored.

  • offset (Integer) (defaults to: 0)

    ignored.

  • parent (Structure) (defaults to: nil)

    ignored.

  • index (Integer) (defaults to: nil)

    ignored.

  • length (Integer) (defaults to: nil)

    if given the length of the vector. Else the length is considered to be 1.

Returns:

  • (Integer)

    the type sizeof(uint8_t) * length.



# File 'lib/libbin/data_types.rb', line 3