Class: Sigma::ByteArray

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/byte_array.rb

Overview

Array of Bytes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



13
14
15
# File 'lib/sigma/byte_array.rb', line 13

def pointer
  @pointer
end

Class Method Details

.from_bytes(bytes) ⇒ ByteArray

Create ByteArray of Array of unsigned 8-bit ints (bytes)

Parameters:

  • bytes (Array<uint8>)

    Array of 8-bit integers (0-255)

Returns:



18
19
20
21
22
23
24
25
# File 'lib/sigma/byte_array.rb', line 18

def self.from_bytes(bytes)
  pointer = FFI::MemoryPointer.new(:pointer)
  b_ptr = FFI::MemoryPointer.new(:uint8, bytes.size)
  b_ptr.write_array_of_uint8(bytes)
  error = ergo_lib_byte_array_from_raw_parts(b_ptr, bytes.size, pointer)
  Util.check_error!(error)
  init(pointer)
end

.with_raw_pointer(pointer) ⇒ ByteArray

Note:

A user of sigma_rb generally does not need to call this function

Takes ownership of an existing ByteArray Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



31
32
33
# File 'lib/sigma/byte_array.rb', line 31

def self.with_raw_pointer(pointer)
  init(pointer)
end