Class: Sigma::SecretKeys

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

Overview

An ordered collection of SecretKey

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



89
90
91
# File 'lib/sigma/secret_key.rb', line 89

def pointer
  @pointer
end

Class Method Details

.createSecretKeys

Create an empty collection

Returns:



101
102
103
104
105
106
# File 'lib/sigma/secret_key.rb', line 101

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

  init(pointer)
end

.with_raw_pointer(unread_pointer) ⇒ SecretKeys

Note:

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

Takes ownership of an existing SecretKeys Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



95
96
97
# File 'lib/sigma/secret_key.rb', line 95

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

Instance Method Details

#add(secret_key) ⇒ Object

Add to collection

Parameters:



116
117
118
# File 'lib/sigma/secret_key.rb', line 116

def add(secret_key)
  ergo_lib_secret_keys_add(secret_key.pointer, self.pointer)
end

#get(index) ⇒ SecretKey?

Get item at specified index or return nil if no item exists

Parameters:

  • index (Integer)

Returns:



123
124
125
126
127
128
129
130
131
132
# File 'lib/sigma/secret_key.rb', line 123

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

#lenInteger

Get length of collection

Returns:

  • (Integer)


110
111
112
# File 'lib/sigma/secret_key.rb', line 110

def len
  ergo_lib_secret_keys_len(self.pointer)
end