Class: Sigma::ByteArrays

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



51
52
53
# File 'lib/sigma/byte_array.rb', line 51

def pointer
  @pointer
end

Class Method Details

.createObject



57
58
59
60
61
62
# File 'lib/sigma/byte_array.rb', line 57

def self.create
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_byte_arrays_new(pointer)

  init(pointer)
end

.with_raw_pointer(unread_pointer) ⇒ Object



53
54
55
# File 'lib/sigma/byte_array.rb', line 53

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

Instance Method Details

#add(byte_array) ⇒ Object



68
69
70
# File 'lib/sigma/byte_array.rb', line 68

def add(byte_array)
  ergo_lib_byte_arrays_add(byte_array.pointer, self.pointer)
end

#get(index) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/sigma/byte_array.rb', line 72

def get(index)
  pointer = FFI::MemoryPointer.new(:pointer)
  res = ergo_lib_byte_arrays_get(self.pointer, index, pointer)
  Util.check_error!(res[:error])
  if res[:is_some]
    Sigma::ByteArray.with_raw_pointer(pointer)
  else
    nil
  end
end

#lenObject



64
65
66
# File 'lib/sigma/byte_array.rb', line 64

def len
  ergo_lib_byte_arrays_len(self.pointer)
end