Class: Sigma::ByteArrays
- Inherits:
-
Object
- Object
- Sigma::ByteArrays
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/byte_array.rb
Overview
An ordered collection of ByteArray
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.create ⇒ ByteArrays
Create an empty collection.
-
.with_raw_pointer(unread_pointer) ⇒ ByteArrays
Takes ownership of an existing ByteArrays Pointer.
Instance Method Summary collapse
-
#add(byte_array) ⇒ Object
Add an item to collection.
-
#get(index) ⇒ ByteArray?
Get item at specified index or return nil if no item exists.
-
#len ⇒ Integer
Get length of collection.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
60 61 62 |
# File 'lib/sigma/byte_array.rb', line 60 def pointer @pointer end |
Class Method Details
.create ⇒ ByteArrays
Create an empty collection
72 73 74 75 76 77 |
# File 'lib/sigma/byte_array.rb', line 72 def self.create pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_byte_arrays_new(pointer) init(pointer) end |
.with_raw_pointer(unread_pointer) ⇒ ByteArrays
Note:
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing ByteArrays Pointer.
66 67 68 |
# File 'lib/sigma/byte_array.rb', line 66 def self.with_raw_pointer(unread_pointer) init(unread_pointer) end |
Instance Method Details
#add(byte_array) ⇒ Object
Add an item to collection
87 88 89 |
# File 'lib/sigma/byte_array.rb', line 87 def add(byte_array) ergo_lib_byte_arrays_add(byte_array.pointer, self.pointer) end |
#get(index) ⇒ ByteArray?
Get item at specified index or return nil if no item exists
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/sigma/byte_array.rb', line 94 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 |
#len ⇒ Integer
Get length of collection
81 82 83 |
# File 'lib/sigma/byte_array.rb', line 81 def len ergo_lib_byte_arrays_len(self.pointer) end |