Class: Sigma::BlockIds
- Inherits:
-
Object
- Object
- Sigma::BlockIds
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/block_header.rb
Overview
An ordered collection of BlockId
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.create ⇒ BlockIds
Create an empty collection.
-
.with_raw_pointer(unread_pointer) ⇒ BlockIds
Takes ownership of an existing BlockIds Pointer.
Instance Method Summary collapse
-
#add(block_id) ⇒ Object
Add to collection.
-
#get(index) ⇒ BlockId?
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.
186 187 188 |
# File 'lib/sigma/block_header.rb', line 186 def pointer @pointer end |
Class Method Details
.create ⇒ BlockIds
Create an empty collection
198 199 200 201 202 203 |
# File 'lib/sigma/block_header.rb', line 198 def self.create pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_block_ids_new(pointer) init(pointer) end |
.with_raw_pointer(unread_pointer) ⇒ BlockIds
Note:
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing BlockIds Pointer.
192 193 194 |
# File 'lib/sigma/block_header.rb', line 192 def self.with_raw_pointer(unread_pointer) init(unread_pointer) end |
Instance Method Details
#add(block_id) ⇒ Object
Add to collection
213 214 215 |
# File 'lib/sigma/block_header.rb', line 213 def add(block_id) ergo_lib_block_ids_add(block_id.pointer, self.pointer) end |
#get(index) ⇒ BlockId?
Get item at specified index or return nil if no item exists
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/sigma/block_header.rb', line 220 def get(index) pointer = FFI::MemoryPointer.new(:pointer) res = ergo_lib_block_ids_get(self.pointer, index, pointer) Util.check_error!(res[:error]) if res[:is_some] Sigma::BlockId.with_raw_pointer(pointer) else nil end end |
#len ⇒ Integer
Get length of collection
207 208 209 |
# File 'lib/sigma/block_header.rb', line 207 def len ergo_lib_block_ids_len(self.pointer) end |