Class: Toybox::Lang::ByteArray

Inherits:
Object
  • Object
show all

Overview

ByteArray objects are fixed size, numerically indexed, single dimensional, and take Numbers with a value >= -128 and <= 255 as members.

Since:

  • 3.0.0

Instance Method Summary collapse

Methods inherited from Object

method, weak

Instance Method Details

add(byte) ⇒ Toybox::Lang::ByteArray

Add a byte to the end of a ByteArray.

When adding a byte, the ByteArray size is increased and new bytes are inserted at the end.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


7071
7072
# File 'Monkeybrains.rb', line 7071

def add(byte)
end

addAll(array) ⇒ Toybox::Lang::ByteArray

Add a ByteArray or an Array of bytes to the end of a ByteArray.

When adding an array of bytes, the ByteArray is expanded by the size of the provided ByteArray or Array, and all of the new elements are inserted starting at the new index.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


7087
7088
# File 'Monkeybrains.rb', line 7087

def addAll(array)
end

decodeNumber(format, options) ⇒ Toybox::Lang::Number, ...

Decodes a portion of the array to a number based on a specified format

Parameters:

Options Hash (options):

Returns:

Raises:

Since:

  • 3.1.0


7237
7238
# File 'Monkeybrains.rb', line 7237

def decodeNumber(format, options)
end

encodeNumber(value, format, options) ⇒ Object

Encodes a number into the byte array

Parameters:

Options Hash (options):

Raises:

Since:

  • 3.1.0


7253
7254
# File 'Monkeybrains.rb', line 7253

def encodeNumber(value, format, options)
end

equals(object) ⇒ Toybox::Lang::Boolean

Test if an Object instance is equal to another instance of an Object.

Examples:

var a = [ 1, 2 ]b;
var b = [ 1, 2 ]b;
var c = [ 1, 2 ];
a.equals(b); // returns true
a.equals(c); // returns false

Parameters:

Returns:

Since:

  • 3.0.0


7214
7215
# File 'Monkeybrains.rb', line 7214

def equals(object)
end

hashCodeToybox::Lang::Number

Get a hash code value for a ByteArray.

Returns:

Since:

  • 3.0.0


7220
7221
# File 'Monkeybrains.rb', line 7220

def hashCode()
end

indexOf(byte) ⇒ Toybox::Lang::Number

Get the index of a byte within the ByteArray.

Parameters:

Returns:

  • (Toybox::Lang::Number)

    The index of the first instance of the provided byte in the ByteArray. If the byte is not found, -1 is returned.

Raises:

Since:

  • 3.0.0


7106
7107
# File 'Monkeybrains.rb', line 7106

def indexOf(byte)
end

remove(byte) ⇒ Toybox::Lang::Boolean

Remove a byte from a ByteArray.

If the passed byte is found, the ByteArray size is decreased by one and elements beyond it are shifted to the next lower index. If the ByteArray has multiple matches, the matching byte at the lowest index will be removed but the other matching bytes will not be removed.

If no byte is provided as an argument, the ByteArray will remain unchanged and remove() will return false.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


7132
7133
# File 'Monkeybrains.rb', line 7132

def remove(byte)
end

removeAll(byte) ⇒ Toybox::Lang::Boolean

Remove bytes from a ByteArray.

For each instance of the byte that is found, the ByteArray size is decreased by one and elements beyond it are shifted to the next lower index.

If no byte is given as an argument, the ByteArray will remain unchanged and removeAll() will return false.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


7157
7158
# File 'Monkeybrains.rb', line 7157

def removeAll(byte)
end

reverseToybox::Lang::ByteArray

Return a new ByteArray that contains the elements of a source ByteArray in reverse order.

Returns:

Since:

  • 3.0.0


7166
7167
# File 'Monkeybrains.rb', line 7166

def reverse()
end

sizeToybox::Lang::Number

Get the size of a ByteArray.

Returns:

Since:

  • 3.0.0


7173
7174
# File 'Monkeybrains.rb', line 7173

def size()
end

slice(startIndex, endIndex) ⇒ Toybox::Lang::ByteArray

Get a new ByteArray containing a portion of an existing ByteArray.

Parameters:

  • startIndex (Toybox::Lang::Number)

    A zero-based index of the start of the new ByteArray. If a negative startIndex is provided, it will offset from the end of the ByteArray. If the startIndex is null, the slice will begin at 0. An out-of-bounds index will be truncated to the ByteArray limits.

  • endIndex (Toybox::Lang::Number)

    A zero-based index of the end of the new ByteArray. Items are included up to, but not including endIndex. If a negative endIndex is provided, it will offset from the end of the ByteArray. If endIndex is null, the slice will end at the last element. An out-of-bounds index is truncated to the ByteArray limits.

Returns:

Since:

  • 3.0.0


7192
7193
# File 'Monkeybrains.rb', line 7192

def slice(startIndex, endIndex)
end

toStringToybox::Lang::String

Convert a ByteArray to a String.

This does not convert the elements of the ByteArray into Strings, but transforms the entire ByteArray into a String.

Returns:

Since:

  • 3.0.0


7201
7202
# File 'Monkeybrains.rb', line 7201

def toString()
end